猿问

为什么fluentWait()速度慢?

fluentWait()在我的selenium代码上使用。但是我注意到,尽管需要等待的元素已经加载到浏览器中,但仍在等待一段时间。这浪费很多时间,但我不知道原因。有谁知道为什么吗?


qq_花开花谢_0
浏览 224回答 1
1回答

蝴蝶不菲

每个FluentWait实例都定义了等待条件的最长时间,以及检查条件的频率。此外,用户可以配置等待以在等待时忽略特定类型的异常,例如在页面上搜索元素时的NoSuchElementExceptions。  // Waiting 30 seconds for an element to be present on the page, checking  // for its presence once every 5 seconds.  Wait wait = new FluentWait(driver)    .withTimeout(30, SECONDS)    .pollingEvery(5, SECONDS)    .ignoring(NoSuchElementException.class);会变慢,因为:  // Waiting 30 seconds for an element to be present on the page, checking  // for its presence once every 1 second.  Wait wait = new FluentWait(driver)    .withTimeout(30, SECONDS)    .pollingEvery(1, SECONDS)    .ignoring(NoSuchElementException.class);因此,这取决于您将使用什么。
随时随地看视频慕课网APP

相关分类

Java
我要回答