gpt4 book ai didi

java - 使用 wait 方法迭代 selenium 中的参与者列表时出现错误

转载 作者:行者123 更新时间:2023-12-01 18:59:55 26 4
gpt4 key购买 nike

当我调试程序时,所有 3 个参与者都被选中,但当我运行时,第二个参与者会出现错误

java.lang.IllegalStateException:找不到网络成员

输入列表具有以下值

  1. 群组成员
  2. 网络成员
  3. LD管理员

This is the selector Xpath for dropdown

  public MessagesPage findRecipient(List userRecipient) throws InterruptedException {


int userCount = userRecipient.size();
int index=0;
for( Object tempUser : userRecipient){
WebElement rightUser = null;
SeleniumUtils.waitElementVisible(driver, searchUser);
searchUser.sendKeys(tempUser.toString());

//output element of drop down search user name
By byUserSearchResult = By.xpath("//tbody[@class='js-pages']/tr/td");

//Wait till the user list is available.
new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(byUserSearchResult));
List<WebElement> resultTable = driver.findElements(byUserSearchResult);

//The code is failing here for 3rd element in the list
for (WebElement user : resultTable) {
String check = user.getText();
if (check.contentEquals(tempUser.toString())) rightUser = user;
}

if (rightUser == null)
throw new IllegalStateException("The " + tempUser.toString() + " can not be found");

rightUser.click();

}

最佳答案

您需要为每个项目引发 WebDriverWait (elementToBeClickable)。

new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(rightUser));
rightUser.click();

关于java - 使用 wait 方法迭代 selenium 中的参与者列表时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59646865/

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