Skip to content
Advertisement

Best way to check that element is not present using Selenium WebDriver with java

Im trying the code below but it seems it does not work… Can someone show me the best way to do this?

JavaScript

Advertisement

Answer

i usually couple of methods (in pair) for verification whether element is present or not:

JavaScript

Note that sometimes selenium can find elements in DOM but they can be invisible, consequently selenium will not be able to interact with them. So in this case method checking for visibility helps.

If you want to wait for the element until it appears the best solution i found is to use fluent wait:

JavaScript

Hope this helps)

Advertisement