Method: Appium::Core::Wait.until
- Defined in:
- lib/appium_lib_core/common/wait.rb
.until(timeout: DEFAULT_TIMEOUT, interval: DEFAULT_INTERVAL, message: nil, ignored: nil, object: nil) ⇒ Object
Check every interval seconds to see if yield doesn’t raise an exception. Give up after timeout seconds.
If only a number is provided then it’s treated as the timeout value.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/appium_lib_core/common/wait.rb', line 47 def until(timeout: DEFAULT_TIMEOUT, interval: DEFAULT_INTERVAL, message: nil, ignored: nil, object: nil) ignored = Array(ignored || ::Exception) last_error = nil timer = Wait::Timer.new(timeout) until timer.timeout? begin return yield(object) rescue ::Errno::ECONNREFUSED => e raise e rescue *ignored => last_error # swallowed end sleep interval end msg = timeout, # steep:ignore:start msg += " (#{last_error.message})" if last_error # steep:ignore:end raise TimeoutError, msg end |