问题
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