[英]how to find the inner elements when all div class name and span class name are same using jsoup in java
[英]How to wait ALL elements with the same class name?
請參見下面的部分代碼:
public class OrderDetailsDashboard extends AbstractTestNGSpringContextTests {
By orderDetails = By.cssSelector(".col-md-12 span strong");
By orderMoreDetails = By.cssSelector(".row.panel-info-summary span strong");
By refundOrderButton = By.cssSelector(".refund-order-action");
public orderDetails getOrderDetails(WebDriver driver) {
logger.info("About to collect and returns the specific order details - refreshing page");
WebDriverWait waitForTitle = new WebDriverWait(driver,30);
try {
waitForTitle.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(orderMoreDetails));
}
catch (StaleElementReferenceException ex) {
waitForTitle.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(orderMoreDetails));
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
waitForTitle.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(orderDetails));
我有一個似乎可以解決的問題,但是我對解決方案不滿意。 我正在嘗試使用自動化功能加載頁面。下一個元素(在此表示為頁面對象):
By orderDetails = By.cssSelector(".col-md-12 span strong")
在我的頁面上顯示了6次,僅包含粗體字。 我已經注意到,當我嘗試獲取第7個元素文本時,盡管使用了wait()
方法,但我卻得到Index Out Of Bounds Exception
。最后,我意識到了wait()
確實在等待,但不是全部元素被重新發送,這就是我的測試失敗的原因(這也是我添加thread.sleep
方法的原因)。
有什么方法可以使用wait()
方法來實際等待頁面上的所有元素?
您可以等待任何條件,因此我猜元素列表應為預期大小。
您是否嘗試過findElementsBy()
???
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.