bot13
bot13

Reputation: 99

driver.findelements(by.xpath()) returning zero

I am trying to find out the no. of orders in the following picture using
//*[@id='past-orders-tab']/div[contains(@class,'physical')] enter image description here

but it is returning zero using .size() ( storing in List[WebElement]) .When i picked one order using findelement() ,it is working fine. Here's the page source code enter image description here

How to correct it?

Upvotes: 2

Views: 2102

Answers (1)

Saurabh Gaur
Saurabh Gaur

Reputation: 23805

You should try using WebDriverWait to wait until there is at least one element present on a web page as below :-

WebDriverWait wait = new WebDriverWait(driver, 10);
List<WebElement> ord = wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.cssSelector("#past-orders-tab > div.physical")));

Upvotes: 1

Related Questions