Home > other >  ElementNotVisibleException not available in Selenium 4
ElementNotVisibleException not available in Selenium 4

Time:08-04

I have some methods that are used to wait for an element to display, and in the try/catch for these methods, the catch is:

throw new ElementNotVisibleException()

I'm upgrading from Selenium 2.53 to Selenium 4, and ElementNotVisibleException() seems to not be available in Selenium 4. What should I replace it with? Is ElementNotInteractableException a suitable replacement?

CodePudding user response:

Since release 4.1.3, the method ElementNotVisibleException() has been removed from selenium/java/src/org/openqa/selenium

See v4.1.2, where the classes ElementNotVisibleException & ElementNotSelectableException exist.

See v4.1.3, where the aforementioned classes have been removed.

This is due to the following:

Selenium 4 is more strict regarding W3C WebDriver, and W3C WebDriver has nothing to say about visibility at this point. If an element is not visible, the driver in W3C mode should return a ElementNotInteractableException

So methods using the ElementNotVisibleException.java class will have to be updated to use ElementNotInteractableException.java

Confirmation here: [

  • Related