問題描述
故事:
在 Java selenium 語言綁定中有一個 FluentWait
類,允許嚴格控制如何檢查預期條件:
In Java selenium language bindings there is a FluentWait
class, that allows to tightly control how the expected condition would be checked:
每個 FluentWait 實例定義等待的最長時間對于條件,以及檢查的頻率狀況.此外,用戶可以將等待配置為忽略等待期間的特定類型的異常,例如在頁面上搜索元素時出現 NoSuchElementExceptions.
Each FluentWait instance defines the maximum amount of time to wait for a condition, as well as the frequency with which to check the condition. Furthermore, the user may configure the wait to ignore specific types of exceptions whilst waiting, such as NoSuchElementExceptions when searching for an element on the page.
換句話說,可以更改應用預期條件檢查的輪詢間隔,默認為 500 毫秒.另外,可以設置要忽略的異常.
In other words, it's possible to change the polling interval in which the expected condition check is applied, which is by default 500ms. Plus, it's possible to set exceptions to ignore.
在Python中也可以,有相關的poll_frequency
和 ignored_exceptions
參數到 WebDriverWait
類.
It is also possible in Python, there are relevant poll_frequency
and ignored_exceptions
arguments to WebDriverWait
class.
問題:
在Protractor/WebDriverJS中使用browser.wait()
時,是否可以控制驗證預期條件的輪詢頻率?
Is it possible to control the poll frequency in which the expected condition is verified when using browser.wait()
in Protractor/WebDriverJS?
根據browser.wait()
文檔,只有 3 個可能的參數:作為預期條件的函數、超時值和可選的超時錯誤消息.我希望有不同的設置或方法來更改投票頻率.
According to the browser.wait()
documentation, there are only 3 possible arguments: a function which is an expected condition, a timeout value and an optional timeout error message. I hope there is a different setting or way to change the poll frequency.
推薦答案
在@Kirill S.的幫助下,經過進一步研究和檢查WebdriverJS
源代碼,我可以得出結論 javascript selenium 中沒有輪詢頻率"之類的東西綁定.無法配置后續條件檢查調用之間的間隔 - 它會盡快執行檢查.
With the help of @Kirill S., after the further research and inspecting the WebdriverJS
source code, I can conclude that there is no such thing as "poll frequency" in javascript selenium bindings. The interval between subsequent condition check calls cannot be configured - it performs the check as quick as possible.
這與 Python 或 Java selenium 綁定中的情況不同,其中在預期的條件狀態檢查之間存在可配置的超時.默認情況下,會等待 500ms 再進行下一次檢查:
This is not the same as in, for instance Python or Java selenium bindings, where there is a configurable timeout between the expected condition state checks. By default, it would wait for 500ms before the next check:
WebDriverWait 默認每 500 次調用 ExpectedCondition毫秒 直到它成功返回.一個成功的回報是ExpectedCondition 類型為 Boolean 返回 true 或非 null 返回值對于所有其他 ExpectedCondition 類型.
WebDriverWait by default calls the ExpectedCondition every 500 milliseconds until it returns successfully. A successful return is for ExpectedCondition type is Boolean return true or not null return value for all other ExpectedCondition types.
這篇關于控制 browser.wait() 的輪詢頻率(流利等待)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!