對于我在代碼早期設定的 webdriver
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS);
然后我宣告了類似的東西
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(bla bla
或者
new WebDriverWait(driver, 5).until(bla bla
它似乎沒有我期望的效果,因為它等待的時間超過 5 秒
這些超時的規則是什么?
uj5u.com熱心網友回復:
您永遠不應該將隱式等待與顯式等待混為一談。
這意味著如果您為您定義了非默認值,implicitlyWait則不應WebDriverWait在該驅動程式會話中使用。
看官方推薦的說法Warning: Do not mix implicit and explicit waits. Doing so can cause unpredictable wait times. For example, setting an implicit wait of 10 seconds and an explicit wait of 15 seconds could cause a timeout to occur after 20 seconds。
通常我們總是使用WebDriverWait顯式等待只保留implicitlyWait設定為默認值0。您可以在此處和更多類似的討論中
看到更多解釋。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/514462.html
