Skip to content

Commit

Permalink
Accept timeout argument to avoid Selenium::WebDriver::Error::TimeoutE…
Browse files Browse the repository at this point in the history
…rror
  • Loading branch information
kaidotdev committed Oct 15, 2024
1 parent aa46f31 commit 995ce09
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/bucky/test_equipment/user_operation/user_operation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def back(_)

def input(args)
# when input successfully, return of click is nil.
wait_until_helper(5, 0.1, Selenium::WebDriver::Error::StaleElementReferenceError) { @pages.get_part(args).send_keys(args[:word]).nil? }
wait_until_helper((args || {}).fetch(:timeout, 5), 0.1, Selenium::WebDriver::Error::StaleElementReferenceError) { @pages.get_part(args).send_keys(args[:word]).nil? }
end

# Clear textbox
Expand All @@ -38,7 +38,7 @@ def clear(args)
def click(args)
elem = @pages.get_part(args)
# when click successfully, return of click is nil.
wait_until_helper(5, 0.1, Selenium::WebDriver::Error::WebDriverError) { elem.click.nil? }
wait_until_helper((args || {}).fetch(:timeout, 5), 0.1, Selenium::WebDriver::Error::WebDriverError) { elem.click.nil? }
end

def refresh(_)
Expand Down Expand Up @@ -68,7 +68,7 @@ def switch_to_oldest_window(_)

def switch_to_the_window(args)
# when the window successfully switched, return of switch_to.window is nil.
wait_until_helper(5, 0.1, Selenium::WebDriver::Error::NoSuchWindowError) { @driver.switch_to.window(args[:window_name]).nil? }
wait_until_helper((args || {}).fetch(:timeout, 5), 0.1, Selenium::WebDriver::Error::NoSuchWindowError) { @driver.switch_to.window(args[:window_name]).nil? }
end

# Close window
Expand All @@ -84,7 +84,7 @@ def stop(_)
end

def choose(args)
option = wait_until_helper(5, 0.1, Selenium::WebDriver::Error::StaleElementReferenceError) { Selenium::WebDriver::Support::Select.new(@pages.get_part(args)) }
option = wait_until_helper((args || {}).fetch(:timeout, 5), 0.1, Selenium::WebDriver::Error::StaleElementReferenceError) { Selenium::WebDriver::Support::Select.new(@pages.get_part(args)) }
if args.key?(:text)
type = :text
selected = args[type].to_s
Expand All @@ -101,8 +101,8 @@ def choose(args)
end

# Alert accept
def accept_alert(_)
alert = wait_until_helper(5, 0.1, Selenium::WebDriver::Error::NoAlertPresentError) { @driver.switch_to.alert }
def accept_alert(args)
alert = wait_until_helper((args || {}).fetch(:timeout, 5), 0.1, Selenium::WebDriver::Error::NoAlertPresentError) { @driver.switch_to.alert }
alert.accept
end

Expand Down

0 comments on commit 995ce09

Please sign in to comment.