且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何减少Selenium中NoSuchElementException的等待时间?

更新时间:2022-03-04 08:51:33

我认为您正在为驾驶员设置隐式等待时间:

I think you're looking for setting the implitic wait time for your driver:

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

对于可以使用的简单情况,对于更高级的自动化,我将其更改为显式等待(使用WebDriverWait).

For simple cases thats ok to use, for more advanced automation, I'd change it to an explicit wait (using WebDriverWait).

更多等待: http://www.seleniumhq.org/docs/04_webdriver_advanced.jsp