06
Oct

How to recreate ElementNotVisibleException in Selenium WebDriver

ElementNotVisibleException : 
Selenium throws ElementNotVisibleException when user tries to perform an operation on an web element, which is present in the page but the element is currently not visible.
Reasons : 
1. Clicking a element which is not visible
2. sendkeys to element which is not visible
3. Element may not be visible because there are more elements under different pages, but those page source code is still present in cache. 

Code which causes the ElementNotVisibleException :
<input type='button' hidden=true value='save'>

// click the button which is hidden (not visible)
driver.findElement(By.xpath("//input[@type='button']")).click();