Difference between visiblityOfAllElementsLocatedBy() and presenceOfAllElementsLocatedBy() in selenium?

Viewed 3239

What is difference between

wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector(".form-checkbox.notext")));

and

wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.cssSelector(".form-checkbox.notext")));
2 Answers

From docs:

https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html

public static ExpectedCondition<java.util.List<WebElement>> visibilityOfAllElementsLocatedBy(By locator)

An expectation for checking that all elements present on the web page that match the locator are visible. Visibility means that the elements are not only displayed but also have a height and width that is greater than 0.

public static ExpectedCondition<java.util.List<WebElement>> presenceOfAllElementsLocatedBy(By locator)

An expectation for checking that there is at least one element present on a web page.

visibilityOfAllElementsLocatedBy(By locator)

public static ExpectedCondition<java.util.List<WebElement>> visibilityOfAllElementsLocatedBy(By locator)

An expectation for checking that all elements present on the web page that match the locator are visible. Visibility means that the elements are not only displayed but also have a height and width that is greater than 0.

please find the help document here : https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html#visibilityOfAllElementsLocatedBy-org.openqa.selenium.By-

presenceOfAllElementsLocatedBy

public static ExpectedCondition<java.util.List<WebElement>> presenceOfAllElementsLocatedBy(By locator)

An expectation for checking that there is at least one element present on a web page.

Please find the Doc here : https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html#presenceOfAllElementsLocatedBy-org.openqa.selenium.By-

Related