【问题标题】:Which is the best way to iterate the list of elements from bottom to up?从下到上迭代元素列表的最佳方法是什么?
【发布时间】:2019-07-26 11:11:47
【问题描述】:
for (int i = listofdisplayedDates.size(); i >= 1; i--)
{
    WebElement Test = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@id='session']//div[@class='hrlis'][+i+]")));
}

【问题讨论】:

    标签: java selenium xpath


    【解决方案1】:

    试试下面的代码。希望这会有所帮助。

    WebDriverWait wait = new WebDriverWait(driver, 30);
    List<WebElement> listofdisplayedDates =wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//div[@id='session']//div[@class='hrlis']")));
    for (int i =listofdisplayedDates.size()-1; i>=0; i--) {
            WebElement Test =listofdisplayedDates.get(i);
        }
    

    【讨论】:

    • 如果它解决了您的问题,请通过单击“否决”按钮下的空心来接受答案。所以它会变成绿色。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-10
    • 2011-11-18
    • 2012-04-22
    • 2019-08-24
    • 2012-05-30
    • 1970-01-01
    • 2016-05-05
    相关资源
    最近更新 更多