Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How to solve elementnotvisibleexception in selenium webdriver?


Asked by Sunny Montoya on Dec 14, 2021 FAQ



Solutions for ElementNotVisibleException in Selenium Webdriver First Solution: Try to write unique XPATH that matches with a single element only. Second Solution: Use Explicit waitfeature of Selenium and wait till the element is not visible. Once it is visible then you can perform your operations.
Also Know,
If you are trying to interact with a particular web element that is present in DOM, but selenium is unable to interact with an element on a web page, then you will get ElementNotVisibleException exception. Your locator is right but still you are getting an exception. Why ?
Next, One can find a complete list of Selenium WebDriver Exceptions in the documentation given by Selenium, but below are a few standard Selenium exceptions faced while running a test : ElementNotVisibleException: In spite of the element being present in the DOM, it is not visible (can not be interactive).
Besides,
You are confused why is it so? When locator is incorrect, selenium webdriver throws “NoSuchElementException”. Above exception says, webdriver is able to locate element, but not able to click on desired element or element is not visible. But your locator might be wrong as well in case of nested web element.
Likewise,
Due to wrong selector or selector, which is, not exist. This Exception occurs when the element presence is in DOM, it is not visible. Hidden Elements, which has presence in DOM and it, is not visible. Visibility means the height and width should be greater than zero.