Friday, January 31, 2014

Element is not currently visible and so may not be interacted with

This page was somewhat helpful, but did not mention the "transform" style needing to be checked. Then I found this fellow using C# who mentioned the transform value. When I put the two together I came up with this solution:
((JavascriptExecutor)driver).executeScript(
   "arguments[0].style.transform = 'none';",
   myFavoriteElement
);
After setting transform = 'none', myFavoriteElement.sendKeys() did not fail with the infamous error:
Element is not currently visible and so may not be interacted with(..)
So I guess we should add transform != 'none' to the list as follows:
  • visibility != hidden
  • display != none (is also checked against every parent element)
  • opacity != 0 (in rc2 this is no longer checked for clicking an element)
  • height and width are both > 0
  • for an input, the attribute type != hidden
  • transform != 'none'
This issue was found using selenium.version = 2.35.0

NOTE: myFavoriteElement was an input type=file generated by the PrimeFaces fileUpload tag. PrimeFaces 4.0 looks like it introduced the transform. Also, when I checked to see what the transform value was before setting it to none, it logged: myFavoriteElement.getCssValue("transform") = matrix(4, 0, 0, 4, -300, 0).

Hope that helps.