lib/appium_lib/common/helper.rb in appium_lib-0.3.3 vs lib/appium_lib/common/helper.rb in appium_lib-0.3.4
- old
+ new
@@ -18,16 +18,18 @@
#
# find_element :text doesn't work so use XPath to find by text.
# Check every 0.5 seconds to see if block.call is true.
# 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 &block
+ def wait max_wait=30, interval=0.5, &block
# Rescue Timeout::Error: execution expired
result = nil
- timeout(30) { until (result = begin; block.call; rescue; end) do; sleep 0.5 end }
+ timeout(max_wait) { until (result = begin; block.call; rescue; end) do; sleep interval end }
result
end
# Presses the back button on Android.
# @return [void]
@@ -156,6 +158,6 @@
end
def find_names name
find_elements :name, name
end
-end # module Appium::Common
\ No newline at end of file
+end # module Appium::Common