Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

What is difference between

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

and

wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.cssSelector(".form-checkbox.notext")));
like image 736
Saroj Purbey Avatar asked Oct 16 '25 20:10

Saroj Purbey


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.

like image 189
Shiva Avatar answered Oct 18 '25 13:10

Shiva


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-

like image 38
koushick Avatar answered Oct 18 '25 13:10

koushick