I have list of web element, when I apply listName.size() function on list, it shows count as 1.
Where as in actual the count is not 1.

Below things I have tried -

  1. Tried applying implicit and explicit wait in order to load the long list of web elements properly.
  2. Tried wait.until(ExpectedConditions.visibilityOfElementLocated(listName));

java code :

List<WebElement> listName= driver.findElements(By.xpath("xpath"));
int count = listName.size();

I want the count exact as the number elements of list found by using xpath. Note: The xpath is valid and correct. Can locate the elements manually with that xpath.

1 Answers

0
DebanjanB On

If your usecase is to print the size() of the List matching a specific Locator Strategy instead of using visibilityOfElementLocated() you need to use either of the following solutions: