gpt4 book ai didi

java - 通过 Java 使用 Selenium 显示计数为 1 的 WebElements 列表

转载 作者:行者123 更新时间:2023-12-02 06:01:58 25 4
gpt4 key购买 nike

I have list of web element, when I apply listName.size() function on list, it shows count as 1.
Where as in actual the count is not 1.

以下是我尝试过的事情 -

  1. Tried applying implicit and explicit wait in order to load the long list of web elements properly.
  2. Tried wait.until(ExpectedConditions.visibilityOfElementLocated(listName));

java代码:

List<WebElement> listName= driver.findElements(By.xpath("xpath"));
int count = listName.size();

我希望计数与使用 xpath 找到的列表元素的数量完全相同。注意:xpath 有效且正确。可以使用该 xpath 手动定位元素。

最佳答案

如果您的用例是打印与特定 Locator Strategy 匹配的 Listsize()您需要使用以下任一解决方案,而不是使用 visibilityOfElementLocated():

关于java - 通过 Java 使用 Selenium 显示计数为 1 的 WebElements 列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55969775/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com