driver.findelements(by.xpath())返回零

时间:2016-09-26 14:34:22

标签: selenium selenium-webdriver

我试图找出答案。以下图片中的订单使用
      //*[@id='past-orders-tab']/div[contains(@class,'physical')]        enter image description here

但它使用.size()返回零(存储在List [WebElement]中) 。当我使用findelement()选择一个订单时,它工作正常。这是页面源代码enter image description here

如何纠正?

1 个答案:

答案 0 :(得分:1)

您应该尝试使用WebDriverWait等到网页上至少有一个元素存在,如下所示: -

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