From 995ce09766df6a1265aca5789259722042bc5270 Mon Sep 17 00:00:00 2001 From: aiharakai Date: Tue, 15 Oct 2024 16:13:16 +0900 Subject: [PATCH] Accept timeout argument to avoid Selenium::WebDriver::Error::TimeoutError --- .../user_operation/user_operation_helper.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/bucky/test_equipment/user_operation/user_operation_helper.rb b/lib/bucky/test_equipment/user_operation/user_operation_helper.rb index a735c6a..0e56148 100644 --- a/lib/bucky/test_equipment/user_operation/user_operation_helper.rb +++ b/lib/bucky/test_equipment/user_operation/user_operation_helper.rb @@ -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 @@ -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(_) @@ -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 @@ -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 @@ -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