class Bucky::TestEquipment::UserOperation::UserOperationHelper
Public Class Methods
new(args)
click to toggle source
# File lib/bucky/test_equipment/user_operation/user_operation_helper.rb, line 11 def initialize(args) @app = args[:app] @device = args[:device] @driver = args[:driver] @pages = args[:pages] end
Public Instance Methods
accept_alert(_)
click to toggle source
Alert accept
# File lib/bucky/test_equipment/user_operation/user_operation_helper.rb, line 104 def accept_alert(_) alert = wait_until_helper(5, 0.1, Selenium::WebDriver::Error::NoAlertPresentError) { @driver.switch_to.alert } alert.accept end
back(_)
click to toggle source
# File lib/bucky/test_equipment/user_operation/user_operation_helper.rb, line 24 def back(_) @driver.navigate.back end
choose(args)
click to toggle source
# File lib/bucky/test_equipment/user_operation/user_operation_helper.rb, line 86 def choose(args) option = wait_until_helper(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 elsif args.key?(:value) type = :value selected = args[type].to_s elsif args.key?(:index) type = :index selected = args[type].to_i else raise StandardError, "Included invalid key #{args.keys}" end option.select_by(type, selected) end
clear(args)
click to toggle source
Clear textbox
# File lib/bucky/test_equipment/user_operation/user_operation_helper.rb, line 34 def clear(args) @pages.get_part(args).clear end
click(args)
click to toggle source
# File lib/bucky/test_equipment/user_operation/user_operation_helper.rb, line 38 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? } end
close(_)
click to toggle source
Close window
# File lib/bucky/test_equipment/user_operation/user_operation_helper.rb, line 75 def close(_) window_index = @driver.window_handles.index(@driver.window_handle) @driver.close @driver.switch_to.window(@driver.window_handles[window_index-1]) end
go(args)
click to toggle source
Open url @param [Hash]
# File lib/bucky/test_equipment/user_operation/user_operation_helper.rb, line 20 def go(args) @driver.navigate.to args[:url] end
input(args)
click to toggle source
# File lib/bucky/test_equipment/user_operation/user_operation_helper.rb, line 28 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? } end
refresh(_)
click to toggle source
# File lib/bucky/test_equipment/user_operation/user_operation_helper.rb, line 44 def refresh(_) @driver.navigate.refresh end
stop(_)
click to toggle source
# File lib/bucky/test_equipment/user_operation/user_operation_helper.rb, line 81 def stop(_) puts 'stop. press enter to continue' gets end
switch_to_newest_window(_)
click to toggle source
# File lib/bucky/test_equipment/user_operation/user_operation_helper.rb, line 61 def switch_to_newest_window(_) @driver.switch_to.window(@driver.window_handles.last) end
switch_to_next_window(_)
click to toggle source
# File lib/bucky/test_equipment/user_operation/user_operation_helper.rb, line 48 def switch_to_next_window(_) window_index = @driver.window_handles.index(@driver.window_handle) windows_number = @driver.window_handles.size unless window_index+1 == windows_number @driver.switch_to.window(@driver.window_handles[window_index+1]) end end
switch_to_oldest_window(_)
click to toggle source
# File lib/bucky/test_equipment/user_operation/user_operation_helper.rb, line 65 def switch_to_oldest_window(_) @driver.switch_to.window(@driver.window_handles.first) end
switch_to_previous_window(_)
click to toggle source
# File lib/bucky/test_equipment/user_operation/user_operation_helper.rb, line 56 def switch_to_previous_window(_) window_index = @driver.window_handles.index(@driver.window_handle) @driver.switch_to.window(@driver.window_handles[window_index-1]) end
switch_to_the_window(args)
click to toggle source
# File lib/bucky/test_equipment/user_operation/user_operation_helper.rb, line 69 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? } end
wait(args)
click to toggle source
# File lib/bucky/test_equipment/user_operation/user_operation_helper.rb, line 109 def wait(args) # Indent print ' ' * 6 args[:sec].times do |count| print "#{count + 1} " sleep 1 end puts '' end