0

*我stale element Exception在这部分得到了一个:

我从表中获取 id

这是导致陈旧元素的部分:


latestId.click();
        
    

我试过:使用下面的代码:

 WebDriverWait wait = new WebDriverWait(driver,10);```
  wait.until(ExpectedConditions.refreshed(ExpectedConditions.stalenessOf(latestId)));

基本上在方法中,因为 id.click() 和 createdvalue("id",latestid.gettexxt()) 都存在它导致问题。

我能得到一个解决方案吗..如果需要可以添加更多信息*

4

1 回答 1

0

您尚未共享元素的 ID 查找代码。

我建议你这样做:

  1. 通过其已知 ID 再次查找该元素。
  2. 等待元素可点击
  3. 点击它

代码:

    WebDriverWait wait = new WebDriverWait(driver, 30);
    WebElement myElement = wait.until(ExpectedConditions.elementToBeClickable(By.id("TheID")));
    try {
        Actions builder = new Actions(browser);
        builder.moveToElement(myElement).click().build().perform();
    } catch (Exception x1) {
        myElement.click();
    }
于 2021-08-24T16:00:20.607 回答