lib/appium_lib/common/helper.rb in appium_lib-0.10.0 vs lib/appium_lib/common/helper.rb in appium_lib-0.11.0

- old
+ new

@@ -28,11 +28,19 @@ # @param max_wait [Integer] the maximum time in seconds to wait for. # Note that max wait 0 means infinity. # @param interval [Float] the time in seconds to wait after calling the block # @param block [Block] the block to call # @return [Object] the result of block.call - def wait max_wait=30, interval=0.5, &block + def wait max_wait=-1, interval=0.5, &block + if max_wait == -1 + max_wait = begin + $driver.default_wait + rescue + end + max_wait ||= 30 + end + # Rescue Timeout::Error: execution expired result = nil timeout max_wait do until (result = begin; block.call || true; rescue; end) sleep interval @@ -50,10 +58,18 @@ # Give up after 30 seconds. # @param max_wait [Integer] the maximum time in seconds to wait for # @param interval [Float] the time in seconds to wait after calling the block # @param block [Block] the block to call # @return [Object] the result of block.call - def wait_true max_wait=30, interval=0.5, &block + def wait_true max_wait=-1, interval=0.5, &block + if max_wait == -1 + max_wait = begin + $driver.default_wait + rescue + end + max_wait ||= 30 + end + # Rescue Timeout::Error: execution expired result = nil timeout max_wait do until (result = begin; block.call; rescue; end) sleep interval \ No newline at end of file