且构网

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

Selenium WebDriver 中的隐式等待和显式等待有什么区别?

更新时间:2022-12-15 15:53:23

查看以下链接:

  • 隐式等待 - 它通过轮询 DOM 指示 Web 驱动程序等待一段时间.一旦您声明了隐式等待,它将在 Web 驱动程序实例的整个生命周期中可用.默认情况下,该值为 0.如果您设置更长的默认值,则该行为将根据浏览器/驱动程序实现定期轮询 DOM.

  • Implicit Wait - It instructs the web driver to wait for some time by poll the DOM. Once you declared implicit wait it will be available for the entire life of web driver instance. By default the value will be 0. If you set a longer default, then the behavior will poll the DOM on a periodic basis depending on the browser/driver implementation.

显式等待 + ExpectedConditions代码> - 这是自定义的.如果我们希望执行等待一段时间直到达到某个条件,就会使用它.

Explicit Wait + ExpectedConditions - It is the custom one. It will be used if we want the execution to wait for some time until some condition achieved.