Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 15 additions & 29 deletions lib/core/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,16 +423,11 @@ def end_record(action)
# NoRaise
def click(action)
start = Time.now
return unless wait_for(action)

action["Condition"] = nil
start_error = Time.now

el = wait_for(action)
return unless el

now = Time.now
log_info("Time to find element: #{now - start - (now - start_error) / 2}s " +
"error #{(now - start_error)}") if action["CheckTime"]
log_info("Time to find element: #{now - start}s") if action["CheckTime"]
error = nil

wait_time = (action["CheckTime"] ? action["CheckTime"] : @timeout)
Expand Down Expand Up @@ -490,16 +485,11 @@ def tap_by_coord(action)
# NoRaise
def press(action)
start = Time.now
return unless wait_for(action)

action["Condition"] = nil
start_error = Time.now

el = wait_for(action)
return unless el

now = Time.now
log_info("Time to find element: #{now - start - (now - start_error) / 2}s " +
"error #{(now - start_error)}") if action["CheckTime"]
log_info("Time to find element: #{now - start}s") if action["CheckTime"]
error = nil

wait_time = (action["CheckTime"] ? action["CheckTime"] : @timeout)
Expand Down Expand Up @@ -528,16 +518,11 @@ def press(action)
# NoRaise
def click_and_hold(action)
start = Time.now
return unless wait_for(action)

action["Condition"] = nil
start_error = Time.now

el = wait_for(action)
return unless el

now = Time.now
log_info("Time to find element: #{now - start - (now - start_error) / 2}s " +
"error #{(now - start_error)}") if action["CheckTime"]
log_info("Time to find element: #{now - start}s") if action["CheckTime"]
error = nil

wait_time = (action["CheckTime"] ? action["CheckTime"] : @timeout)
Expand Down Expand Up @@ -933,16 +918,15 @@ def wait_for(action)
wait_time = (action["CheckTime"] ? action["CheckTime"] : wait_time)
index = action["Index"]

el = nil
exception = ""
start = Time.now
try = 0
while (Time.now - start) < wait_time
if id.is_a?(String)

if id.is_a?(String)
id = convert_value(id)
locator_strategy = convert_value(locator_strategy)
while (Time.now - start) < wait_time
begin
id = convert_value(id)
locator_strategy = convert_value(locator_strategy)
try += 1
el = nil
if index
els = @driver.find_elements(locator_strategy, id)
if index.is_a?(String) && index == "last"
Expand All @@ -959,7 +943,9 @@ def wait_for(action)
exception = e
sleep(0.2)
end
else
end
else
while (Time.now - start) < wait_time
i = 0
id.each do |locator|
locator = convert_value(locator)
Expand Down