Skip to content

Commit 4edc9f6

Browse files
Add params to wait
1 parent da1c042 commit 4edc9f6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/appium_lib/common/helper.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ module Appium::Common
2020

2121
# Check every 0.5 seconds to see if block.call is true.
2222
# Give up after 30 seconds.
23+
# @param max_wait [Integer] the maximum time in seconds to wait for
24+
# @param interval [Float] the time in seconds to wait after calling the block
2325
# @param block [Block] the block to call
2426
# @return [Object] the result of block.call
25-
def wait &block
27+
def wait max_wait=30, interval=0.5, &block
2628
# Rescue Timeout::Error: execution expired
2729
result = nil
28-
timeout(30) { until (result = begin; block.call; rescue; end) do; sleep 0.5 end }
30+
timeout(max_wait) { until (result = begin; block.call; rescue; end) do; sleep interval end }
2931
result
3032
end
3133

@@ -158,4 +160,4 @@ def find_name name
158160
def find_names name
159161
find_elements :name, name
160162
end
161-
end # module Appium::Common
163+
end # module Appium::Common

0 commit comments

Comments
 (0)