硒有时无法识别元素
Selenium does not recognize an element in some of the times
我有一种元素,selenium 有时无法识别。
我正在使用 10 秒的 implicitlyWait
,当我运行测试时,有时它会成功通过并识别元素,有时它会因错误 "No such element" 而失败。
我尝试将等待时间更改为 20 秒,但没关系
尝试使用显式等待:
WebDriverWait wait = new WebDriverWait(webDriver,60);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div/div/div/div/div[1]/div/div/a/i")));
我也遇到过一次这个问题,我遇到这个问题是因为我试图 select 通过点击主菜单然后点击子菜单来选择子菜单中的一些选项。
使用 Actions class 时,问题已解决。
这对您来说也可能是个问题。
我有一种元素,selenium 有时无法识别。
我正在使用 10 秒的 implicitlyWait
,当我运行测试时,有时它会成功通过并识别元素,有时它会因错误 "No such element" 而失败。
我尝试将等待时间更改为 20 秒,但没关系
尝试使用显式等待:
WebDriverWait wait = new WebDriverWait(webDriver,60); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div/div/div/div/div[1]/div/div/a/i")));
我也遇到过一次这个问题,我遇到这个问题是因为我试图 select 通过点击主菜单然后点击子菜单来选择子菜单中的一些选项。 使用 Actions class 时,问题已解决。 这对您来说也可能是个问题。