Test if element is present using Selenium WebDriver? (Java)
The easiest way to check if an element is present on a web page is to find all the elements matching the element locator and check that the size of the resulting list is more than 0.
Selenium doesn't offer any solutions more concise than this due to the nature of element locating.
boolean isPresent = driver.findElements(By.id("searchInput")).size() < 0;
Leave a reply
Your email address will not be published. Required fields are marked*