Top Level Namespace
- Includes:
- RbConfig
Defined Under Namespace
Modules: ITMS Classes: TestCaseFailed
Constant Summary collapse
- WAIT =
WAIT instance for explicit wait
Selenium::WebDriver::Wait.new(:timeout => 30)
Instance Method Summary collapse
- #add_selection(element, label) ⇒ Object
- #answer_on_next_prompt(answer) ⇒ Object
- #assert(var_name, value) ⇒ Object
-
#assert_alert(text) ⇒ Object
method to check javascript pop-up alert text.
-
#assert_checked(element) ⇒ Object
method to assert checkbox check param 1 : String : Element.
-
#assert_confirmation(text) ⇒ Object
method to check javascript pop-up alert text.
- #assert_editable(element) ⇒ Object
-
#assert_element_not_present(element) ⇒ Object
method to check element not presence param 1: String: Element.
-
#assert_element_present(element) ⇒ Object
method to check element presence param 1: String: Element.
- #assert_not_checked(element) ⇒ Object
- #assert_not_editable ⇒ Object
- #assert_not_selected_value(element, text) ⇒ Object
- #assert_not_text(element, text) ⇒ Object
- #assert_prompt(text) ⇒ Object
- #assert_selected_label(element, text) ⇒ Object
- #assert_selected_value(text) ⇒ Object
-
#assert_text(element, expected_value) ⇒ Object
Method to check element text param 1 : String : Element param 2 : String : Expected element text.
-
#assert_title(title) ⇒ Object
Method to verify title param 1: String : expected title.
- #assert_value(element, text) ⇒ Object
-
#check(element) ⇒ Object
method to check checkbox.
- #check_using_variable(text) ⇒ Object
- #choose_cancel_on_next_confirmation ⇒ Object
- #choose_cancel_on_next_prompt ⇒ Object
- #choose_ok_on_next_confirmation ⇒ Object
- #click(element) ⇒ Object
- #click_at(element) ⇒ Object
- #close ⇒ Object
-
#compare_image(actual_img_access_type, actual_img_access_name, excp_img_access_type, excp_img_access_name) ⇒ Object
Method to compare two images param 1 : String : Locator type (id, name, class, xpath, css, url) param 2 : String : Locator value param 3 : String : Locator type (id, name, class, xpath, css, url, image_name) param 4 : String : Locator value.
-
#compare_jpeg_images(expected_img_url, actual_img_url) ⇒ Object
Comparing jpg images.
-
#compare_png_images(expected_img_url, actual_img_url) ⇒ Object
Comparing png images.
- #debugger ⇒ Object
-
#does_images_similar?(actual_img_access_type, actual_img_access_name, excp_img_access_type, excp_img_access_name) ⇒ Boolean
Method to find difference between images.
- #double_click(element) ⇒ Object
- #double_click_at(element, location) ⇒ Object
- #drag_and_drop_to_object(element, drop_element) ⇒ Object
- #echo(message) ⇒ Object
- #edit_content(element, text) ⇒ Object
- #else_if(condition_script) ⇒ Object
- #find_object(string_object) ⇒ Object
-
#get_device_info ⇒ Object
Return android device name and android version using adb command.
-
#get_key ⇒ Object
method to return key by os wise.
- #handle_alert(decesion) ⇒ Object
- #if(condition_script) ⇒ Object
- #load_object_repository ⇒ Object
- #loadYAMLfile(filename) ⇒ Object
- #long_press(element, duration) ⇒ Object
-
#maximize_browser ⇒ Object
Method to maximize browser.
-
#mouse_down(element) ⇒ Object
mouse_down.
-
#mouse_down_at(element, location) ⇒ Object
mouse_down_at.
-
#mouse_move_at ⇒ Object
mouse_move_at.
-
#mouse_out ⇒ Object
mouse_out.
-
#mouse_over(element) ⇒ Object
Method to hover on element.
-
#mouse_up(element) ⇒ Object
mouse_up.
-
#mouse_up_at ⇒ Object
mouse_up_at.
-
#navigate(direction) ⇒ Object
method to navigate back & forward.
- #number_or_nil(string) ⇒ Object
-
#open(link) ⇒ Object
method to open link.
- #pause(time) ⇒ Object
-
#print_congifugartion ⇒ Object
method to print configuration.
-
#print_desktop_configuration ⇒ Object
method to print desktop configuration.
-
#print_error_android(browser_type, app_path) ⇒ Object
print error for android.
-
#print_error_android_app ⇒ Object
print error for android app.
-
#print_error_android_web ⇒ Object
print error for android web.
-
#print_error_desktop ⇒ Object
print error for desktop.
-
#print_error_ios ⇒ Object
print error for ios.
-
#print_error_ios_app ⇒ Object
print error for ios app.
-
#print_error_ios_web ⇒ Object
print error for ios web.
- #print_error_object_repository ⇒ Object
-
#print_invalid_platform ⇒ Object
print error if invalid platform.
-
#print_mobile_configuration ⇒ Object
method to print mobile configuration.
-
#quit ⇒ Object
method to quite webdriver instance.
-
#refresh_page ⇒ Object
Method to refresh page.
- #remove_selection(element, label) ⇒ Object
-
#scroll_page(to) ⇒ Object
method to scroll page to top or end.
-
#scroll_to_element(element) ⇒ Object
Method to scroll page to perticular element.
- #select(element) ⇒ Object
-
#select_all_option_from_multiselect_dropdown(element) ⇒ Object
method to select all option from dropdwon list.
- #select_frame(element) ⇒ Object
-
#select_option_from_dropdown(element, by, option) ⇒ Object
method to select option from dropdwon list.
-
#select_option_from_radio_button_group(element, by, option) ⇒ Object
method to select option from radio button group.
-
#select_radio_button(element) ⇒ Object
method to select radio button.
- #select_window(element) ⇒ Object
-
#send_keys(element, key) ⇒ Object
method to send keys.
-
#set_window_size(resolution) ⇒ Object
Method to resize browser.
- #store(var_name, value) ⇒ Object
- #store_attribute(element, attribute, var_name) ⇒ Object
- #store_json(var_name, value) ⇒ Object
- #store_text(element, var_name) ⇒ Object
- #store_title(var_name) ⇒ Object
- #store_window_handle(var_name) ⇒ Object
- #store_xpath_count(element, var_name) ⇒ Object
- #take_screenshot ⇒ Object
-
#toggle_checkbox(element) ⇒ Object
method to toggle checkbox checked.
-
#type(element, text) ⇒ Object
method to enter text into textfield.
-
#uncheck(element) ⇒ Object
method to uncheck checkbox.
-
#unselect_all_option_from_multiselect_dropdown(element) ⇒ Object
method to unselect all option from dropdwon list.
-
#valid_locator_type?(type) ⇒ Boolean
method to validate locator.
-
#valid_option_by?(option_by) ⇒ Boolean
method to validate dropdown selector.
- #validate_locator(type) ⇒ Object
- #validate_option_by(option_by) ⇒ Object
-
#validate_parameters(platform, browser_type, app_path) ⇒ Object
Method to check browser type.
- #verify(var_name, value) ⇒ Object
-
#verify_checked(element) ⇒ Object
method to assert checkbox check param 1 : String : Element.
- #verify_editable(element) ⇒ Object
-
#verify_element_not_present(element) ⇒ Object
method to check element not presence param 1: String: Element.
-
#verify_element_present(element) ⇒ Object
method to check element presence param 1: String: Element.
- #verify_not_checked(element) ⇒ Object
- #verify_not_editable ⇒ Object
- #verify_not_selected_value(element, text) ⇒ Object
- #verify_not_text(element, text) ⇒ Object
- #verify_selected_label(element, text) ⇒ Object
- #verify_selected_value(text) ⇒ Object
-
#verify_text(element, expected_value) ⇒ Object
Method to check element text param 1 : String : Element param 2 : String : Expected element text.
-
#verify_title(title) ⇒ Object
Method to verify title param 1: String : expected title.
- #verify_value(element, text) ⇒ Object
- #wait_for_element_editable(element, duration) ⇒ Object
- #wait_for_element_not_editable(element, duration) ⇒ Object
- #wait_for_element_not_present(element, duration) ⇒ Object
- #wait_for_element_not_visible(element, duration) ⇒ Object
- #wait_for_element_present(element, duration) ⇒ Object
- #wait_for_element_visible(element, duration) ⇒ Object
- #wait_for_text(element, text) ⇒ Object
- #webdriver_answer_on_visible_prompt(answer) ⇒ Object
- #webdriver_choose_cancel_on_visible_confirmation ⇒ Object
- #webdriver_choose_cancel_on_visible_prompt ⇒ Object
- #webdriver_choose_ok_on_visible_confirmation ⇒ Object
- #while(condition_script) ⇒ Object
-
#zoom_in_out(in_out) ⇒ Object
Method to zoom in/out page.
-
#zoom_in_out_till_element_display(element, in_out) ⇒ Object
Method to zoom in/out web page until web element dislays.
Instance Method Details
#add_selection(element, label) ⇒ Object
81 82 83 84 85 |
# File 'lib/itms_automation/methods/input_methods.rb', line 81 def add_selection(element, label) value = check_is_using_variable(label) found_element = find_object(element) found_element.find_element(:xpath, "//option[. = '#{value}']").click end |
#answer_on_next_prompt(answer) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/itms_automation/methods/progress_methods.rb', line 56 def answer_on_next_prompt(answer) value = check_is_using_variable(answer) alert = $driver.switch_to.alert alert.send_keys(value) alert.accept() end |
#assert(var_name, value) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 115 def assert(var_name, value) if (value == "true" || value == "false") _value = value else elseif (value == '0' || !!number_or_nil(value)) _value = value end result = if _value expect($vars[var_name]).to eq(_value) else expect($vars[var_name]).to eq(value) end end |
#assert_alert(text) ⇒ Object
method to check javascript pop-up alert text
51 52 53 54 55 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 51 def assert_alert(text) value = check_is_using_variable(text) alert_text = $driver.switch_to.alert.text expect(alert_text).to eq(value) end |
#assert_checked(element) ⇒ Object
method to assert checkbox check param 1 : String : Element
40 41 42 43 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 40 def assert_checked(element) checkbox = find_object(element) expect(checkbox.selected?).to be_truthy end |
#assert_confirmation(text) ⇒ Object
method to check javascript pop-up alert text
58 59 60 61 62 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 58 def assert_confirmation(text) value = check_is_using_variable(text) alert_text = $driver.switch_to.alert.text expect(alert_text).to eq(value) end |
#assert_editable(element) ⇒ Object
64 65 66 67 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 64 def assert_editable(element) found_element = find_object(element) expect(found_element.enabled?).to be_truthy end |
#assert_element_not_present(element) ⇒ Object
method to check element not presence param 1: String: Element
33 34 35 36 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 33 def assert_element_not_present(element) found_element = find_object(element) expect(found_element.length).to eq(0) end |
#assert_element_present(element) ⇒ Object
method to check element presence param 1: String: Element
26 27 28 29 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 26 def assert_element_present(element) found_element = find_object(element) expect(found_element.length).to be > 0 end |
#assert_not_checked(element) ⇒ Object
45 46 47 48 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 45 def assert_not_checked(element) checkbox = find_object(element) expect(checkbox.selected?).to be_falsey end |
#assert_not_editable ⇒ Object
69 70 71 72 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 69 def assert_not_editable found_element = find_object(element) expect(found_element.enabled?).to be_falsey end |
#assert_not_selected_value(element, text) ⇒ Object
74 75 76 77 78 79 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 74 def assert_not_selected_value(element, text) value = check_is_using_variable(text) found_element = find_object(element) value = found_element.attribute("value") expect(value).not_to eq(value) end |
#assert_not_text(element, text) ⇒ Object
81 82 83 84 85 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 81 def assert_not_text(element, text) value = check_is_using_variable(text) found_element = find_object(element) expect(found_element.text).not_to eq(value) end |
#assert_prompt(text) ⇒ Object
87 88 89 90 91 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 87 def assert_prompt(text) value = check_is_using_variable(text) alert_text = $driver.switch_to.alert.text expect(alert_text).to eq(value) end |
#assert_selected_label(element, text) ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 93 def assert_selected_label(element, text) value = check_is_using_variable(text) found_element = find_object(element) locator = "option[@value='#{found_element.attribute('value')}']" selected_text = found_element.find_element(:xpath, locator).text expect(selected_text).to eq(value) end |
#assert_selected_value(text) ⇒ Object
108 109 110 111 112 113 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 108 def assert_selected_value(text) value = check_is_using_variable(text) found_element = find_object(element) value = found_element.attribute("value") expect(value).to eq(value) end |
#assert_text(element, expected_value) ⇒ Object
Method to check element text param 1 : String : Element param 2 : String : Expected element text
17 18 19 20 21 22 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 17 def assert_text(element, expected_value) text = check_is_using_variable(expected_value) found_element = find_object(element) element_text = found_element.text expect(element_text).to eq(text) end |
#assert_title(title) ⇒ Object
Method to verify title param 1: String : expected title
9 10 11 12 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 9 def assert_title(title) text = check_is_using_variable(title) expect($driver.title).to eq(text) end |
#assert_value(element, text) ⇒ Object
101 102 103 104 105 106 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 101 def assert_value(element, text) value = check_is_using_variable(text) found_element = find_object(element) value = found_element.attribute("value") expect(value).to eq(value) end |
#check(element) ⇒ Object
method to check checkbox
44 45 46 47 |
# File 'lib/itms_automation/methods/input_methods.rb', line 44 def check(element) checkbox = find_object(element) checkbox.click unless checkbox.selected? end |
#check_using_variable(text) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/itms_automation/methods/misc_methods.rb', line 66 def check_using_variable(text) regex = /\$\{(.*?)\}/ text.scan(regex).each do |var| value = $vars[var[0].to_sym] if value replace = "${#{var[0]}}" text.gsub!(replace, "#{value}") end end text end |
#choose_cancel_on_next_confirmation ⇒ Object
63 64 65 |
# File 'lib/itms_automation/methods/progress_methods.rb', line 63 def choose_cancel_on_next_confirmation $driver.switch_to.alert.dismiss end |
#choose_cancel_on_next_prompt ⇒ Object
67 68 69 |
# File 'lib/itms_automation/methods/progress_methods.rb', line 67 def choose_cancel_on_next_prompt $driver.switch_to.alert.dismiss end |
#choose_ok_on_next_confirmation ⇒ Object
71 72 73 |
# File 'lib/itms_automation/methods/progress_methods.rb', line 71 def choose_ok_on_next_confirmation $driver.switch_to.alert.accept end |
#click(element) ⇒ Object
3 4 5 6 |
# File 'lib/itms_automation/methods/click_elements_methods.rb', line 3 def click(element) found_element = find_object(element) found_element.click end |
#click_at(element) ⇒ Object
8 9 10 11 |
# File 'lib/itms_automation/methods/click_elements_methods.rb', line 8 def click_at(element) found_element = find_object(element) found_element.click end |
#close ⇒ Object
18 19 20 |
# File 'lib/itms_automation/methods/navigate_methods.rb', line 18 def close $drive.close end |
#compare_image(actual_img_access_type, actual_img_access_name, excp_img_access_type, excp_img_access_name) ⇒ Object
Method to compare two images param 1 : String : Locator type (id, name, class, xpath, css, url) param 2 : String : Locator value param 3 : String : Locator type (id, name, class, xpath, css, url, image_name) param 4 : String : Locator value
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 241 def compare_image(actual_img_access_type, actual_img_access_name, excp_img_access_type, excp_img_access_name) if actual_img_access_type == 'url' actual_img_url = actual_img_access_name else actual_img_url = get_element_attribute(actual_img_access_type, actual_img_access_name, 'src') end if excp_img_access_type == 'url' expected_img_url = excp_img_access_name elsif excp_img_access_type == 'image_name' expected_img_url = './features/expected_images/' + excp_img_access_name else expected_img_url = get_element_attribute(excp_img_access_type, excp_img_access_name, 'src') end # replace 'https' with 'http' from actual image url if actual_img_url.include? 'https' actual_img_url['https'] = 'http' end # replace 'https' with 'http' from expected image url if expected_img_url.include? 'https' expected_img_url['https'] = 'http' end if expected_img_url.include? '.png' image_type = 'png' else image_type = 'jpg' end # Storing actual image locally open('./features/actual_images/actual_image.' + image_type, 'wb') do |file| file << open(actual_img_url).read end actual_img_url = './features/actual_images/actual_image.' + image_type # Storing Expected image locally if excp_img_access_type != 'image_name' open('./features/expected_images/expected_image.' + image_type, 'wb') do |file| file << open(expected_img_url).read end expected_img_url = './features/expected_images/expected_image.' + image_type end # Verify image extension and call respective compare function if image_type == 'png' return compare_png_images(expected_img_url, actual_img_url) end compare_jpeg_images(expected_img_url, actual_img_url) end |
#compare_jpeg_images(expected_img_url, actual_img_url) ⇒ Object
Comparing jpg images
296 297 298 299 300 301 302 303 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 296 def compare_jpeg_images(expected_img_url, actual_img_url) if open(expected_img_url).read == open(actual_img_url).read return true else puts 'Difference in images' return false end end |
#compare_png_images(expected_img_url, actual_img_url) ⇒ Object
Comparing png images
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 306 def compare_png_images(expected_img_url, actual_img_url) images = [ ChunkyPNG::Image.from_file(expected_img_url), ChunkyPNG::Image.from_file(actual_img_url) ] diff = [] images.first.height.times do |y| images.first.row(y).each_with_index do |pixel, x| diff << [x, y] unless pixel == images.last[x, y] end end if diff.length != 0 puts "\npixels (total): #{images.first.pixels.length}" puts "pixels changed: #{diff.length}" puts "pixels changed (%): #{(diff.length.to_f / images.first.pixels.length) * 100}%" x, y = diff.map { |xy| xy[0] }, diff.map { |xy| xy[1] } images.last.rect(x.min, y.min, x.max, y.max, ChunkyPNG::Color.rgb(0, 255, 0)) cur_time = Time.now.strftime('%Y%m%d%H%M%S%L') images.last.save("./features/image_difference/difference_#{cur_time}.png") puts "\nDifference between images saved as : difference_#{cur_time}.png\n" return false end true end |
#debugger ⇒ Object
41 42 |
# File 'lib/itms_automation/methods/configuration_methods.rb', line 41 def debugger end |
#does_images_similar?(actual_img_access_type, actual_img_access_name, excp_img_access_type, excp_img_access_name) ⇒ Boolean
Method to find difference between images
230 231 232 233 234 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 230 def does_images_similar?(actual_img_access_type, actual_img_access_name, excp_img_access_type, excp_img_access_name) if !compare_image(actual_img_access_type, actual_img_access_name, excp_img_access_type, excp_img_access_name) raise TestCaseFailed, 'Actual image is different from expected image' end end |
#double_click(element) ⇒ Object
13 14 15 16 |
# File 'lib/itms_automation/methods/click_elements_methods.rb', line 13 def double_click(element) found_element = find_object(element) $driver.action.double_click(found_element).perform end |
#double_click_at(element, location) ⇒ Object
18 19 20 21 |
# File 'lib/itms_automation/methods/click_elements_methods.rb', line 18 def double_click_at(element, location) found_element = find_object(element) $driver.action.double_click(found_element).perform end |
#drag_and_drop_to_object(element, drop_element) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/itms_automation/methods/input_methods.rb', line 98 def drag_and_drop_to_object(element, drop_element) dragged = find_object(element) object_value_regex = /^(class=|css=|id=|name=|xpath=|className=|link=|linkText=|partialLinkText=)/ object_type_regex = /^(class|css|id|name|xpath|className|link|linkText|partialLinkText)/ if object_value_regex.match?(drop_element) object_value = drop_element.gsub(object_value_regex, "") object_type = drop_element.split(object_type_regex)[1].underscore dropped = $driver.find_element(object_type.to_sym, object_value) $driver.action.drag_and_drop(dragged, dropped).perform else raise TestCaseFailed, "Option locator not supported" end end |
#echo(message) ⇒ Object
37 38 39 |
# File 'lib/itms_automation/methods/configuration_methods.rb', line 37 def echo() puts() end |
#edit_content(element, text) ⇒ Object
75 76 77 78 79 |
# File 'lib/itms_automation/methods/input_methods.rb', line 75 def edit_content(element, text) value = check_is_using_variable(text) found_element = find_object(element) $driver.execute_script("if (arguments[0].contentEditable === 'true') {arguments[0].innerText = '#{value}'}", found_element) end |
#else_if(condition_script) ⇒ Object
8 9 10 11 |
# File 'lib/itms_automation/methods/condition_methods.rb', line 8 def else_if(condition_script) value = check_is_using_variable(condition_script) $driver.execute_script(value) end |
#find_object(string_object) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/itms_automation/methods/misc_methods.rb', line 37 def find_object(string_object) $OBJECT = load_object_repository string_object = string_object.gsub(/"/, "'") hash_object = $OBJECT[string_object] if hash_object == nil raise "Object not found - Object: #{string_object} is not found in Object Repository." end locator_type = hash_object.keys.first.to_s locator_value = hash_object[locator_type] validate_locator(locator_type) $driver.find_element(:"#{locator_type}" => "#{locator_value}") end |
#get_device_info ⇒ Object
Return android device name and android version using adb command
29 30 31 32 33 34 35 |
# File 'lib/itms_automation/methods/misc_methods.rb', line 29 def get_device_info IO.popen('adb shell getprop ro.product.brand') { |f| $device = f.gets.chomp.upcase} $device += ' ' IO.popen('adb shell getprop ro.product.model') { |f| $device += f.gets.chomp.upcase} IO.popen('adb shell getprop ro.build.version.release') { |f| $os_version = f.gets.chomp.upcase} return $device, $os_version end |
#get_key ⇒ Object
method to return key by os wise
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/itms_automation/methods/navigate_methods.rb', line 28 def get_key os = Selenium::WebDriver::Platform.os if os.to_s == 'windows' return 'control' elsif os.to_s == 'macosx' return 'command' else raise 'Invalid OS' end end |
#handle_alert(decesion) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/itms_automation/methods/javascript_handling_methods.rb', line 3 def handle_alert(decesion) if decesion == 'accept' $driver.switch_to.alert.accept else $driver.switch_to.alert.dismiss end end |
#if(condition_script) ⇒ Object
3 4 5 6 |
# File 'lib/itms_automation/methods/condition_methods.rb', line 3 def if(condition_script) value = check_is_using_variable(condition_script) $driver.execute_script(value) end |
#load_object_repository ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/itms_automation/methods/misc_methods.rb', line 50 def load_object_repository begin loadYAMLfile("features/step_definitions/repositories/project_object.yml") rescue => exception print_error_object_repository end end |
#loadYAMLfile(filename) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/itms_automation/methods/misc_methods.rb', line 58 def loadYAMLfile(filename) begin return YAML.load_file(filename) rescue Psych::SyntaxError => ex raise "Syntax error when reading file: #{ex}" end end |
#long_press(element, duration) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/itms_automation/methods/click_elements_methods.rb', line 23 def long_press(element, duration) found_element = find_object(element) parameters = { "element" => "#{found_element}", "duration" => "#{duration}" } args = parameters.select { |k, v| [:element, :duration].include? k } args = args_with_ele_ref(args) chain_method(:longPress, args) end |
#maximize_browser ⇒ Object
Method to maximize browser
64 65 66 |
# File 'lib/itms_automation/methods/navigate_methods.rb', line 64 def maximize_browser $driver.manage.window.maximize end |
#mouse_down(element) ⇒ Object
mouse_down
80 81 82 83 |
# File 'lib/itms_automation/methods/navigate_methods.rb', line 80 def mouse_down(element) element = find_object(element) $driver.action.move_to_element(element).click_and_hold.perform end |
#mouse_down_at(element, location) ⇒ Object
mouse_down_at
86 87 88 89 |
# File 'lib/itms_automation/methods/navigate_methods.rb', line 86 def mouse_down_at(element, location) element = find_object(element) $driver.action.move_to_element(element).click_and_hold.perform end |
#mouse_move_at ⇒ Object
mouse_move_at
110 111 112 113 |
# File 'lib/itms_automation/methods/navigate_methods.rb', line 110 def mouse_move_at element = find_object(element) $driver.action.move_to_element(element).perform end |
#mouse_out ⇒ Object
mouse_out
92 93 94 95 |
# File 'lib/itms_automation/methods/navigate_methods.rb', line 92 def mouse_out element = $driver.find_element(By.CSS_SELECTOR, 'body') $driver.action.move_to_element(element, 0, 0).perform end |
#mouse_over(element) ⇒ Object
Method to hover on element
74 75 76 77 |
# File 'lib/itms_automation/methods/navigate_methods.rb', line 74 def mouse_over(element) element = find_object(element) $driver.action.move_to_element(element).perform end |
#mouse_up(element) ⇒ Object
mouse_up
98 99 100 101 |
# File 'lib/itms_automation/methods/navigate_methods.rb', line 98 def mouse_up(element) element = find_object(element) $driver.action.move_to_element(element).release.perform end |
#mouse_up_at ⇒ Object
mouse_up_at
104 105 106 107 |
# File 'lib/itms_automation/methods/navigate_methods.rb', line 104 def mouse_up_at element = find_object(element) $driver.action.move_to_element(element).release.perform end |
#navigate(direction) ⇒ Object
method to navigate back & forward
10 11 12 13 14 15 16 |
# File 'lib/itms_automation/methods/navigate_methods.rb', line 10 def navigate(direction) if direction == 'back' $driver.navigate.back else $driver.navigate.forward end end |
#number_or_nil(string) ⇒ Object
336 337 338 339 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 336 def number_or_nil(string) num = string.to_i num if num.to_s == string end |
#open(link) ⇒ Object
method to open link
4 5 6 7 |
# File 'lib/itms_automation/methods/navigate_methods.rb', line 4 def open(link) value = check_is_using_variable(link) $driver.get(value) end |
#pause(time) ⇒ Object
3 4 5 6 |
# File 'lib/itms_automation/methods/progress_methods.rb', line 3 def pause(time) value = check_is_using_variable(time) sleep value.to_i end |
#print_congifugartion ⇒ Object
method to print configuration
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/itms_automation/methods/configuration_methods.rb', line 4 def print_congifugartion puts '' puts "Date : #{Time.now.strftime("%d-%B-%Y")}" puts "Time : #{Time.now.strftime("%I:%M:%S:%p")}" if $platform == 'android' or $platform == 'ios' print_mobile_configuration else print_desktop_configuration end end |
#print_desktop_configuration ⇒ Object
method to print desktop configuration
17 18 19 20 21 |
# File 'lib/itms_automation/methods/configuration_methods.rb', line 17 def print_desktop_configuration puts 'Platform : ' + Selenium::WebDriver::Platform.os.to_s.upcase puts 'Browser : ' + $driver.capabilities.browser_name.to_s.upcase + " " + $driver.capabilities.version.to_s puts '' end |
#print_error_android(browser_type, app_path) ⇒ Object
print error for android
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/itms_automation/methods/error_handling_methods.rb', line 29 def print_error_android(browser_type, app_path) if browser_type=='firefox' and app_path==nil puts "\nOops... not mentioned \"Browser\" or \"App path\"" print_error_android_app print_error_android_web Process.exit(0) elsif browser_type!='firefox' and !%w(native chrome).include? browser_type puts "\nOops... not supported browser" print_error_android_web Process.exit(0) end end |
#print_error_android_app ⇒ Object
print error for android app
43 44 45 46 |
# File 'lib/itms_automation/methods/error_handling_methods.rb', line 43 def print_error_android_app puts "\nTo run test on android app" puts "\n Usage : cucumber PLATFORM=android APP_PATH=path/to/app" end |
#print_error_android_web ⇒ Object
print error for android web
49 50 51 52 53 |
# File 'lib/itms_automation/methods/error_handling_methods.rb', line 49 def print_error_android_web puts "\nTo run test on android mobile web" puts "\n Usage : cucumber PLATFORM=android BROWSER=browser_name" puts "\n Supported browsers are \"chrome\" and \"native\"" end |
#print_error_desktop ⇒ Object
print error for desktop
20 21 22 23 24 25 26 |
# File 'lib/itms_automation/methods/error_handling_methods.rb', line 20 def print_error_desktop puts "\nInappropraite desktop browser : \"#{ENV['BROWSER']}\"" puts "\nUsage : cucumber BROWSER=browser_name" puts "\nBrowser Supported :\n" puts "\n1.internet_explorer\n2.chrome\n3.firefox\n4.safari\n5.opera\n6.chrome_headless\n7.remote" Process.exit(0) end |
#print_error_ios ⇒ Object
print error for ios
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/itms_automation/methods/error_handling_methods.rb', line 56 def print_error_ios if browser_type=='firefox' and app_path==nil puts "\nOops... not mentioned \"Browser\" or \"App path\"" print_error_ios_app print_error_ios_web Process.exit(0) elsif browser_type!='safari' puts "\nOops... not supported browser" print_error_ios_app_web Process.exit(0) end end |
#print_error_ios_app ⇒ Object
print error for ios app
70 71 72 73 |
# File 'lib/itms_automation/methods/error_handling_methods.rb', line 70 def print_error_ios_app puts "\nTo run test on iOS App" puts "\n Usage : cucumber PLATFORM=iOS APP_PATH=path/to/app" end |
#print_error_ios_web ⇒ Object
print error for ios web
76 77 78 79 |
# File 'lib/itms_automation/methods/error_handling_methods.rb', line 76 def print_error_ios_web puts "\nTo run test on iOS mobile web" puts "\n Usage : cucumber PLATFORM=iOS BROWSER=safari" end |
#print_error_object_repository ⇒ Object
89 90 91 92 93 |
# File 'lib/itms_automation/methods/error_handling_methods.rb', line 89 def print_error_object_repository puts "\nNo Object Repository found." puts "\nPlease create file \"project_object.yml\" in path \"features/step_definitions/repositories/\"" Process.exit(0) end |
#print_invalid_platform ⇒ Object
print error if invalid platform
82 83 84 85 86 87 |
# File 'lib/itms_automation/methods/error_handling_methods.rb', line 82 def print_invalid_platform puts "\nOops... Invalid Platform" puts "\nSupported platform are \"android\" and \"iOS\"." puts "\nTo run on Desktop no need to mention platform." Process.exit(0) end |
#print_mobile_configuration ⇒ Object
method to print mobile configuration
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/itms_automation/methods/configuration_methods.rb', line 24 def print_mobile_configuration puts "Platform : #{$platform.upcase}" puts "OS version : #{$os_version}" puts "Device : #{$device_name}" if $app_path.nil? puts 'Browser : ' + $driver.capabilities.browser_name.to_s.upcase + " " + $driver.capabilities.version.to_s else puts "App Tested : #{$app_path}" end puts '' end |
#quit ⇒ Object
method to quite webdriver instance
23 24 25 |
# File 'lib/itms_automation/methods/navigate_methods.rb', line 23 def quit $driver.quit end |
#refresh_page ⇒ Object
Method to refresh page
69 70 71 |
# File 'lib/itms_automation/methods/navigate_methods.rb', line 69 def refresh_page $driver.navigate.refresh end |
#remove_selection(element, label) ⇒ Object
87 88 89 90 91 |
# File 'lib/itms_automation/methods/input_methods.rb', line 87 def remove_selection(element, label) value = check_is_using_variable(label) found_element = find_object(element) found_element.find_element(:xpath, "//option[. = '#{value}']").click end |
#scroll_page(to) ⇒ Object
method to scroll page to top or end
122 123 124 125 126 127 128 129 130 |
# File 'lib/itms_automation/methods/navigate_methods.rb', line 122 def scroll_page(to) if to == 'end' $driver.execute_script('window.scrollTo(0,Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight));') elsif to == 'top' $driver.execute_script('window.scrollTo(Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight),0);') else raise "Exception : Invalid Direction (only scroll \"top\" or \"end\")" end end |
#scroll_to_element(element) ⇒ Object
Method to scroll page to perticular element
116 117 118 119 |
# File 'lib/itms_automation/methods/navigate_methods.rb', line 116 def scroll_to_element(element) ele_scroll = find_object(element) ele_scroll.location_once_scrolled_into_view end |
#select(element) ⇒ Object
93 94 95 96 |
# File 'lib/itms_automation/methods/input_methods.rb', line 93 def select(element) found_element = find_object(element) found_element.find_element(:xpath, "//option[. = '#{label}']").click end |
#select_all_option_from_multiselect_dropdown(element) ⇒ Object
method to select all option from dropdwon list
30 31 32 33 34 |
# File 'lib/itms_automation/methods/input_methods.rb', line 30 def select_all_option_from_multiselect_dropdown(element) dropdown = WAIT.until { find_object(element) } select_list = Selenium::WebDriver::Support::Select.new(dropdown) select_list.select_all end |
#select_frame(element) ⇒ Object
115 116 |
# File 'lib/itms_automation/methods/input_methods.rb', line 115 def select_frame(element) end |
#select_option_from_dropdown(element, by, option) ⇒ Object
method to select option from dropdwon list
23 24 25 26 27 |
# File 'lib/itms_automation/methods/input_methods.rb', line 23 def select_option_from_dropdown(element, by, option) dropdown = WAIT.until { find_object(element) } select_list = Selenium::WebDriver::Support::Select.new(dropdown) select_list.select_by(:"#{by}", "#{option}") end |
#select_option_from_radio_button_group(element, by, option) ⇒ Object
method to select option from radio button group
67 68 69 70 71 72 73 |
# File 'lib/itms_automation/methods/input_methods.rb', line 67 def (element, by, option) = WAIT.until { find_object(element) } getter = ->(rb, by) { by == 'value' ? rb.attribute('value') : rb.text } ele = .find { |rb| getter.call(rb, by) == option } ele.click unless ele.selected? end |
#select_radio_button(element) ⇒ Object
method to select radio button
61 62 63 64 |
# File 'lib/itms_automation/methods/input_methods.rb', line 61 def (element) = WAIT.until { find_object(element) } .click unless .selected? end |
#select_window(element) ⇒ Object
112 113 |
# File 'lib/itms_automation/methods/input_methods.rb', line 112 def select_window(element) end |
#send_keys(element, key) ⇒ Object
method to send keys
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/itms_automation/methods/input_methods.rb', line 10 def send_keys(element, key) value = check_is_using_variable(key) keys_support = ["KEY_LEFT", "KEY_UP", "KEY_RIGHT", "KEY_DOWN", "KEY_PAGE_UP", "KEY_PAGE_DOWN", "KEY_BACKSPACE", "KEY_DELETE", "KEY_ENTER", "KEY_TAB"] foundElement = find_object(element) if value get_key = value.strip[/^\$\{(.*?)\}$/, 1] raise TestCaseFailed, "${get_key} key is not supported. Supported keys: KEY_LEFT, KEY_UP, KEY_RIGHT, KEY_DOWN, KEY_PAGE_UP, KEY_PAGE_DOWN, KEY_BACKSPACE, KEY_DELETE, KEY_ENTER, KEY_TAB" unless keys_support.include?(get_key) key_convert = get_key[/^KEY_(.*?)$/, 1].downcase.to_sym foundElement.send_keys(key_convert) end end |
#set_window_size(resolution) ⇒ Object
Method to resize browser
56 57 58 59 60 61 |
# File 'lib/itms_automation/methods/navigate_methods.rb', line 56 def set_window_size(resolution) value = check_is_using_variable(resolution) raise TestCaseFailed, 'Wrong format of resolution. (e.g., 1280x800)' unless value.match(/^\d+x\d+$/) width, height = value.split("x") $driver.manage.resize_to(width, heigth) end |
#store(var_name, value) ⇒ Object
3 4 5 |
# File 'lib/itms_automation/methods/store_methods.rb', line 3 def store(var_name, value) $vars[var_name] = value end |
#store_attribute(element, attribute, var_name) ⇒ Object
30 31 32 33 34 |
# File 'lib/itms_automation/methods/store_methods.rb', line 30 def store_attribute(element, attribute, var_name) found_element = find_object(element) value = found_element.attribute(attribute) $vars[var_name] = value end |
#store_json(var_name, value) ⇒ Object
7 8 9 |
# File 'lib/itms_automation/methods/store_methods.rb', line 7 def store_json(var_name, value) $vars[var_name] = JSON.parse(value) end |
#store_text(element, var_name) ⇒ Object
11 12 13 14 15 |
# File 'lib/itms_automation/methods/store_methods.rb', line 11 def store_text(element, var_name) found_element = find_object(element) element_text = found_element.text $vars[var_name] = element_text end |
#store_title(var_name) ⇒ Object
17 18 19 |
# File 'lib/itms_automation/methods/store_methods.rb', line 17 def store_title(var_name) $vars[var_name] = $driver.title end |
#store_window_handle(var_name) ⇒ Object
26 27 28 |
# File 'lib/itms_automation/methods/store_methods.rb', line 26 def store_window_handle(var_name) $vars[var_name] = $driver.window_handle end |
#store_xpath_count(element, var_name) ⇒ Object
21 22 23 24 |
# File 'lib/itms_automation/methods/store_methods.rb', line 21 def store_xpath_count(element, var_name) found_element = find_object(element) $vars[var_name] = found_element.length end |
#take_screenshot ⇒ Object
3 4 5 6 |
# File 'lib/itms_automation/methods/screenshot_methods.rb', line 3 def take_screenshot cur_time = Time.now.strftime('%Y%m%d%H%M%S%L') $driver.save_screenshot('./features/screenshots/screenshot' + cur_time + '.png') end |
#toggle_checkbox(element) ⇒ Object
method to toggle checkbox checked
56 57 58 |
# File 'lib/itms_automation/methods/input_methods.rb', line 56 def toggle_checkbox(element) find_object(element).click end |
#type(element, text) ⇒ Object
method to enter text into textfield
4 5 6 7 |
# File 'lib/itms_automation/methods/input_methods.rb', line 4 def type(element, text) foundElement = find_object(element) foundElement.send_keys(text) end |
#uncheck(element) ⇒ Object
method to uncheck checkbox
50 51 52 53 |
# File 'lib/itms_automation/methods/input_methods.rb', line 50 def uncheck(element) checkbox = find_object(element) checkbox.click if checkbox.selected? end |
#unselect_all_option_from_multiselect_dropdown(element) ⇒ Object
method to unselect all option from dropdwon list
37 38 39 40 41 |
# File 'lib/itms_automation/methods/input_methods.rb', line 37 def unselect_all_option_from_multiselect_dropdown(element) dropdown = WAIT.until { find_object(element) } select_list = Selenium::WebDriver::Support::Select.new(dropdown) select_list.deselect_all end |
#valid_locator_type?(type) ⇒ Boolean
method to validate locator
11 12 13 |
# File 'lib/itms_automation/methods/misc_methods.rb', line 11 def valid_locator_type? type %w(id class css name xpath class_name link link_text partial_link_text).include? type end |
#valid_option_by?(option_by) ⇒ Boolean
method to validate dropdown selector
20 21 22 |
# File 'lib/itms_automation/methods/misc_methods.rb', line 20 def valid_option_by? option_by %w(text value index).include? option_by end |
#validate_locator(type) ⇒ Object
15 16 17 |
# File 'lib/itms_automation/methods/misc_methods.rb', line 15 def validate_locator type raise "Invalid locator type - #{type}" unless valid_locator_type? type end |
#validate_option_by(option_by) ⇒ Object
24 25 26 |
# File 'lib/itms_automation/methods/misc_methods.rb', line 24 def validate_option_by option_by raise "Invalid option by - #{option_by}" unless valid_option_by? option_by end |
#validate_parameters(platform, browser_type, app_path) ⇒ Object
Method to check browser type
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/itms_automation/methods/error_handling_methods.rb', line 4 def validate_parameters(platform, browser_type, app_path) if platform == 'desktop' if !%w(firefox internet_explorer chrome safari opera chrome_headless remote).include? browser_type print_error_desktop end elsif platform == 'android' print_error_android browser_type, app_path elsif platform == 'iOS' puts "Not Implemented..." # print_error_ios browser_type, app_path else print_invalid_platform end end |
#verify(var_name, value) ⇒ Object
216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 216 def verify(var_name, value) if (value == "true" || value == "false") _value = value else elseif (value == '0' || !!number_or_nil(value)) _value = value end result = if _value expect($vars[var_name]).to eq(_value) else expect($vars[var_name]).to eq(value) end end |
#verify_checked(element) ⇒ Object
method to assert checkbox check param 1 : String : Element
161 162 163 164 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 161 def verify_checked(element) checkbox = find_object(element) expect(checkbox.selected?).to be_truthy end |
#verify_editable(element) ⇒ Object
171 172 173 174 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 171 def verify_editable(element) found_element = find_object(element) expect(found_element.enabled?).to be_truthy end |
#verify_element_not_present(element) ⇒ Object
method to check element not presence param 1: String: Element
154 155 156 157 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 154 def verify_element_not_present(element) found_element = find_object(element) expect(found_element.length).to eq(0) end |
#verify_element_present(element) ⇒ Object
method to check element presence param 1: String: Element
147 148 149 150 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 147 def verify_element_present(element) found_element = find_object(element) expect(found_element.length).to be > 0 end |
#verify_not_checked(element) ⇒ Object
166 167 168 169 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 166 def verify_not_checked(element) checkbox = find_object(element) expect(checkbox.selected?).to be_falsey end |
#verify_not_editable ⇒ Object
176 177 178 179 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 176 def verify_not_editable found_element = find_object(element) expect(found_element.enabled?).to be_falsey end |
#verify_not_selected_value(element, text) ⇒ Object
181 182 183 184 185 186 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 181 def verify_not_selected_value(element, text) value = check_is_using_variable(text) found_element = find_object(element) value = found_element.attribute("value") expect(value).not_to eq(value) end |
#verify_not_text(element, text) ⇒ Object
188 189 190 191 192 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 188 def verify_not_text(element, text) value = check_is_using_variable(text) found_element = find_object(element) expect(found_element.text).not_to eq(value) end |
#verify_selected_label(element, text) ⇒ Object
194 195 196 197 198 199 200 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 194 def verify_selected_label(element, text) value = check_is_using_variable(text) found_element = find_object(element) locator = "option[@value='#{found_element.attribute('value')}']" selected_text = found_element.find_element(:xpath, locator).text expect(selected_text).to eq(value) end |
#verify_selected_value(text) ⇒ Object
209 210 211 212 213 214 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 209 def verify_selected_value(text) value = check_is_using_variable(text) found_element = find_object(element) value = found_element.attribute("value") expect(value).to eq(value) end |
#verify_text(element, expected_value) ⇒ Object
Method to check element text param 1 : String : Element param 2 : String : Expected element text
138 139 140 141 142 143 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 138 def verify_text(element, expected_value) text = check_is_using_variable(expected_value) found_element = find_object(element) element_text = found_element.text expect(element_text).to eq(text) end |
#verify_title(title) ⇒ Object
Method to verify title param 1: String : expected title
130 131 132 133 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 130 def verify_title(title) value = check_is_using_variable(title) expect($driver.title).to eq(value) end |
#verify_value(element, text) ⇒ Object
202 203 204 205 206 207 |
# File 'lib/itms_automation/methods/assertion_methods.rb', line 202 def verify_value(element, text) value = check_is_using_variable(text) found_element = find_object(element) value = found_element.attribute("value") expect(value).to eq(value) end |
#wait_for_element_editable(element, duration) ⇒ Object
8 9 10 11 12 |
# File 'lib/itms_automation/methods/progress_methods.rb', line 8 def wait_for_element_editable(element, duration) value = check_is_using_variable(duration) wait = Selenium::WebDriver::Wait.new(:timeout => value.to_i / 1000) wait.until { find_object(element).enabled? } end |
#wait_for_element_not_editable(element, duration) ⇒ Object
14 15 16 17 18 |
# File 'lib/itms_automation/methods/progress_methods.rb', line 14 def wait_for_element_not_editable(element, duration) value = check_is_using_variable(duration) wait = Selenium::WebDriver::Wait.new(:timeout => value.to_i / 1000) wait.until { !find_object(element).enabled? } end |
#wait_for_element_not_present(element, duration) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/itms_automation/methods/progress_methods.rb', line 20 def wait_for_element_not_present(element, duration) value = check_is_using_variable(duration) wait = Selenium::WebDriver::Wait.new(:timeout => value.to_i / 1000) wait.until do begin !find_object(element) rescue Selenium::WebDriver::Error::NoSuchElementError true end end end |
#wait_for_element_not_visible(element, duration) ⇒ Object
32 33 34 35 36 |
# File 'lib/itms_automation/methods/progress_methods.rb', line 32 def wait_for_element_not_visible(element, duration) value = check_is_using_variable(duration) wait = Selenium::WebDriver::Wait.new(:timeout => value.to_i / 1000) wait.until { !find_object(element).displayed? } end |
#wait_for_element_present(element, duration) ⇒ Object
50 51 52 53 54 |
# File 'lib/itms_automation/methods/progress_methods.rb', line 50 def wait_for_element_present(element, duration) value = check_is_using_variable(duration) wait = Selenium::WebDriver::Wait.new(:timeout => value.to_i / 1000) wait.until { find_object(element) } end |
#wait_for_element_visible(element, duration) ⇒ Object
44 45 46 47 48 |
# File 'lib/itms_automation/methods/progress_methods.rb', line 44 def wait_for_element_visible(element, duration) value = check_is_using_variable(duration) wait = Selenium::WebDriver::Wait.new(:timeout => value.to_i / 1000) wait.until { find_object(element).displayed? } end |
#wait_for_text(element, text) ⇒ Object
38 39 40 41 42 |
# File 'lib/itms_automation/methods/progress_methods.rb', line 38 def wait_for_text(element, text) value = check_is_using_variable(text) wait = Selenium::WebDriver::Wait.new(:timeout => 30) wait.until { find_object(element).text == value } end |
#webdriver_answer_on_visible_prompt(answer) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/itms_automation/methods/progress_methods.rb', line 75 def webdriver_answer_on_visible_prompt(answer) value = check_is_using_variable(answer) alert = $driver.switch_to.alert alert.send_keys(value) alert.accept() end |
#webdriver_choose_cancel_on_visible_confirmation ⇒ Object
82 83 84 |
# File 'lib/itms_automation/methods/progress_methods.rb', line 82 def webdriver_choose_cancel_on_visible_confirmation $driver.switch_to.alert.dismiss end |
#webdriver_choose_cancel_on_visible_prompt ⇒ Object
90 91 92 |
# File 'lib/itms_automation/methods/progress_methods.rb', line 90 def webdriver_choose_cancel_on_visible_prompt $driver.switch_to.alert.dismiss end |
#webdriver_choose_ok_on_visible_confirmation ⇒ Object
86 87 88 |
# File 'lib/itms_automation/methods/progress_methods.rb', line 86 def webdriver_choose_ok_on_visible_confirmation $driver.switch_to.alert.accept end |
#while(condition_script) ⇒ Object
13 14 15 16 |
# File 'lib/itms_automation/methods/condition_methods.rb', line 13 def while(condition_script) value = check_is_using_variable(condition_script) $driver.execute_script(value) end |
#zoom_in_out(in_out) ⇒ Object
Method to zoom in/out page
40 41 42 |
# File 'lib/itms_automation/methods/navigate_methods.rb', line 40 def zoom_in_out(in_out) $driver.action.key_down(:"#{get_key}").send_keys(:"#{in_out}").key_up(:"#{get_key}").perform end |
#zoom_in_out_till_element_display(element, in_out) ⇒ Object
Method to zoom in/out web page until web element dislays
45 46 47 48 49 50 51 52 53 |
# File 'lib/itms_automation/methods/navigate_methods.rb', line 45 def zoom_in_out_till_element_display(element, in_out) while true if find_object(element).displayed? break else $driver.action.key_down(:"#{get_key}").send_keys(:"#{in_out}").key_up(:"#{get_key}").perform end end end |