Inconsistently getting error (Watir::Wait::TimeoutError)

◇◆丶佛笑我妖孽 提交于 2020-01-06 08:25:10

问题


I am new to cucumber,while running script at times I am getting error

(Watir::Wait::TimeoutError)

I am not finding any particular pattern to it. Any help will be dearly appreciated.

Many thanks


回答1:


First, ensure you're requiring the proper library for watir-webdriver/wait.

require "watir-webdriver/wait"

Watir has a few methods of declaring wait times on objects, for example (via Watir Webdriver/Waiting):

Explicit waits

There are four built in methods that you can use to make your waiting experience more pleasant (and remove those evil sleep statements from your code)

Watir::Wait.until { ... }   #=> you can wait for a block to be true
object.when_present.set     #=> you can do something when it’s present
object.wait_until_present   #=> you just wait until something is present & visible
object.wait_while_present   #=> you just wait until something disappears


Watir also has a way to set the implicit wait time between execution on the driver occurs.

Implicit waits

As an alternative, you can use the WebDriver’s implicit waits to specify a maximum time (in seconds) the script will try to find an element before timing out. This is done by setting the property of the underlying driver:

require 'watir-webdriver'
b = Watir::Browser.new
b.driver.manage.timeouts.implicit_wait = 3 #=> always wait 3 seconds


来源:https://stackoverflow.com/questions/23340134/inconsistently-getting-error-watirwaittimeouterror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!