I am using Selenium 2 Java API with FirefoxDriver. When I fill a form, checkboxes are added to the page depending the forms inputs.
I'd like to simulate a click on those checkboxes using Selenium. The element are visible and usable in a regular browser but, selenium asserts that the elements are not visible.
"Element is not currently visible and so may not be interacted with"
Can I force selenium to ignore the non-visible state of the elements? How can I force Selenium to interact with the non-visible element?
There is also another case when visible element will be recognized as not visible:
In order to check if element you wan't to interact with is CSS transformed, on CHROME do this:
Or you may use Selenium Action Class to simulate user interaction -- For example
I get into ElementNotVisibleException exception using selenium for functional tests on a django site with bootstrap glyphicons as links in templates as:
During my functional tests, the bootstrap style is not loaded, then trying to click on such links will raise ElementNotVisibleException. I manage to make them clickable just adding a space in the tag, like that:
The accepted answer worked for me. Below is some code to find the parent element that's making Selenium think it's not visible.
I just solve this error by waiting element display property
Selenium determines an element is visible or not by the following criteria (use a DOM inspector to determine what css applies to your element, make sure you look at computed style):
Your element is matching one of those criteria. If you do not have the ability to change the styling of the element, here is how you can forcefully do it with javascript (going to assume WebDriver since you said Selenium2 API):
But that won't fire a javascript event, if you depend on the change event for that input you'll have to fire it too (many ways to do that, easiest to use whatever javascript library is loaded on that page).
The source for the visibility check -
https://github.com/SeleniumHQ/selenium/blob/master/javascript/atoms/dom.js#L577
The WebDriver spec that defines this -
https://dvcs.w3.org/hg/webdriver/raw-file/tip/webdriver-spec.html#widl-WebElement-isDisplayed-boolean