我试图找出答案。以下图片中的订单使用
//*[@id='past-orders-tab']/div[contains(@class,'physical')]
但它使用.size()
返回零(存储在List [WebElement]中)
。当我使用findelement()
选择一个订单时,它工作正常。这是页面源代码
如何纠正?
答案 0 :(得分:1)
您应该尝试使用WebDriverWait
等到网页上至少有一个元素存在,如下所示: -
WebDriverWait wait = new WebDriverWait(driver, 10);
List<WebElement> ord = wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.cssSelector("#past-orders-tab > div.physical")));