Skip to content

Commit 5b3bb88

Browse files
wait and wait_true now respect default_wait
Fix #66
1 parent 5c3083b commit 5b3bb88

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

lib/appium_lib/common/helper.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ module Appium::Common
3030
# @param interval [Float] the time in seconds to wait after calling the block
3131
# @param block [Block] the block to call
3232
# @return [Object] the result of block.call
33-
def wait max_wait=30, interval=0.5, &block
33+
def wait max_wait=-1, interval=0.5, &block
34+
if max_wait == -1
35+
max_wait = begin
36+
$driver.default_wait
37+
rescue
38+
end
39+
max_wait ||= 30
40+
end
41+
3442
# Rescue Timeout::Error: execution expired
3543
result = nil
3644
timeout max_wait do
@@ -52,7 +60,15 @@ def ignore &block
5260
# @param interval [Float] the time in seconds to wait after calling the block
5361
# @param block [Block] the block to call
5462
# @return [Object] the result of block.call
55-
def wait_true max_wait=30, interval=0.5, &block
63+
def wait_true max_wait=-1, interval=0.5, &block
64+
if max_wait == -1
65+
max_wait = begin
66+
$driver.default_wait
67+
rescue
68+
end
69+
max_wait ||= 30
70+
end
71+
5672
# Rescue Timeout::Error: execution expired
5773
result = nil
5874
timeout max_wait do

0 commit comments

Comments
 (0)