webdriver ruby (cucumber watir-webdriver, ), :
def retry_loop(interval = 0.2, times_to_try = 4, &block)
begin
return yield
rescue
sleep(interval)
if (times_to_try -= 1) > 0
retry
end
end
yield
end
, - javascript - , retry_loop :
retry_loop do
assert_contain text, element
end
As you will notice, there is no penalty for performance if it already exists. Obviously, the opposite case (checking that something is NOT there) should always reach a timeout. I like the way that data is stored in the method and in the test code.
Perhaps you could use something similar in C ++?
source
share