我对 NoSuchElementException 的超时时间有疑问,默认情况下似乎是 30 秒,我想缩短它。所以我写了这样的东西:
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("someid")));
element.click();
我收到这条消息:
org.openqa.selenium.TimeoutException: Timed out after 10 seconds waiting for element to be
clickable: By.id: someid
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element:
{"method":"id","selector":"someid"}
Command duration or timeout: 30.03 seconds
所以第一条消息是我希望 WebDriverWait 会覆盖 NoSuchElementException 超时但我仍然得到完整的 30 秒。无论如何,有什么办法可以摆脱这个?