itms_automation 2.1 → 2.5.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/bin/generate.rb +3 -37
  3. data/bin/helper.rb +23 -10
  4. data/bin/itms_automation +18 -23
  5. data/doc/installation.md +16 -0
  6. data/doc/itms-automation-API.md +103 -0
  7. data/doc/itms-automation-help.md +18 -0
  8. data/example/android/android_app/android_app_calculator.zip +0 -0
  9. data/example/android/android_app/android_app_calculator/AndroidCalculator.apk +0 -0
  10. data/example/android/android_app/android_app_calculator/features/calculator.feature +36 -0
  11. data/example/android/android_app/android_app_calculator/features/my_first.feature +13 -0
  12. data/example/android/android_app/android_app_calculator/features/screenshots/test.png +0 -0
  13. data/example/android/android_app/android_app_calculator/features/step_definitions/custom_steps.rb +5 -0
  14. data/example/android/android_app/android_app_calculator/features/support/env.rb +52 -0
  15. data/example/android/android_app/android_app_calculator/features/support/hooks.rb +26 -0
  16. data/example/android/android_web/android_web_gmail_login.zip +0 -0
  17. data/example/android/android_web/android_web_gmail_login/features/gmail_login.feature +12 -0
  18. data/example/android/android_web/android_web_gmail_login/features/my_first.feature +1 -0
  19. data/example/android/android_web/android_web_gmail_login/features/screenshots/test.png +0 -0
  20. data/example/android/android_web/android_web_gmail_login/features/step_definitions/custom_steps.rb +5 -0
  21. data/example/android/android_web/android_web_gmail_login/features/support/env.rb +51 -0
  22. data/example/android/android_web/android_web_gmail_login/features/support/hooks.rb +27 -0
  23. data/example/desktop web/desktop_web_gmail_login.zip +0 -0
  24. data/example/desktop web/desktop_web_gmail_login/features/gmail_login.feature +9 -0
  25. data/example/desktop web/desktop_web_gmail_login/features/gmail_multi_login.feature +21 -0
  26. data/example/desktop web/desktop_web_gmail_login/features/my_first.feature +1 -0
  27. data/example/desktop web/desktop_web_gmail_login/features/screenshots/test.png +0 -0
  28. data/example/desktop web/desktop_web_gmail_login/features/step_definitions/custom_steps.rb +5 -0
  29. data/example/desktop web/desktop_web_gmail_login/features/support/env.rb +51 -0
  30. data/example/desktop web/desktop_web_gmail_login/features/support/hooks.rb +26 -0
  31. data/features-skeleton/my_first.feature +5 -0
  32. data/features-skeleton/screenshots/test.png +0 -0
  33. data/features-skeleton/step_definitions/custom_steps.rb +5 -0
  34. data/features-skeleton/support/env.rb +104 -0
  35. data/features-skeleton/support/hooks.rb +74 -0
  36. data/lib/itms_automation.rb +1 -3
  37. data/lib/itms_automation/assertion_steps.rb +68 -0
  38. data/lib/itms_automation/click_elements_steps.rb +24 -0
  39. data/lib/itms_automation/configuration_steps.rb +7 -0
  40. data/lib/itms_automation/input_steps.rb +59 -0
  41. data/lib/itms_automation/javascript_handling_steps.rb +10 -0
  42. data/lib/itms_automation/methods/assertion_methods.rb +344 -0
  43. data/lib/itms_automation/methods/click_elements_methods.rb +23 -0
  44. data/lib/itms_automation/methods/configuration_methods.rb +35 -0
  45. data/lib/itms_automation/methods/error_handling_methods.rb +87 -0
  46. data/lib/itms_automation/methods/input_methods.rb +69 -0
  47. data/lib/itms_automation/methods/javascript_handling_methods.rb +9 -0
  48. data/lib/itms_automation/methods/misc_methods.rb +47 -0
  49. data/lib/itms_automation/methods/navigate_methods.rb +123 -0
  50. data/lib/itms_automation/methods/progress_methods.rb +15 -0
  51. data/lib/itms_automation/methods/required_files.rb +9 -0
  52. data/lib/itms_automation/methods/screenshot_methods.rb +6 -0
  53. data/lib/itms_automation/navigation_steps.rb +79 -0
  54. data/lib/itms_automation/progress_steps.rb +17 -0
  55. data/lib/itms_automation/screenshot_steps.rb +6 -0
  56. data/lib/itms_automation/version.rb +5 -3
  57. metadata +84 -102
  58. data/bin/console +0 -14
  59. data/bin/documentation_generator.rb +0 -119
  60. data/bin/setup +0 -8
  61. data/lib/itms_automation/all_steps.rb +0 -8
  62. data/lib/itms_automation/assertion_helper.rb +0 -29
  63. data/lib/itms_automation/auto_util.rb +0 -694
  64. data/lib/itms_automation/database_steps_helper.rb +0 -125
  65. data/lib/itms_automation/web_steps_helper.rb +0 -606
  66. data/project/Gemfile +0 -3
  67. data/project/Gemfile.lock +0 -92
  68. data/project/README.md +0 -34
  69. data/project/Rakefile +0 -24
  70. data/project/config/chrome_headless_options.yaml +0 -1
  71. data/project/config/chrome_options.yaml +0 -6
  72. data/project/config/firefox_headless_options.yaml +0 -1
  73. data/project/config/firefox_options.yaml +0 -1
  74. data/project/config/ie_options.yaml +0 -1
  75. data/project/config/remote_options.yaml +0 -6
  76. data/project/config/safari_options.yaml +0 -1
  77. data/project/cucumber.yml +0 -4
  78. data/project/features/TestSuite/WebGUI.feature +0 -5
  79. data/project/features/step_definitions/lib_steps/steps_definition.rb +0 -46
  80. data/project/features/step_definitions/repositories/project_object.yml +0 -26
  81. data/project/features/support/env.rb +0 -9
  82. data/project/features/support/hooks.rb +0 -130
@@ -0,0 +1,35 @@
1
+ require_relative 'required_files'
2
+
3
+ # method to print configuration
4
+ def print_congifugartion
5
+ puts ''
6
+ puts "Date : #{Time.now.strftime("%d-%B-%Y")}"
7
+ puts "Time : #{Time.now.strftime("%I:%M:%S:%p")}"
8
+
9
+ if $platform == 'android' or $platform == 'ios'
10
+ print_mobile_configuration
11
+ else
12
+ print_desktop_configuration
13
+ end
14
+ end
15
+
16
+ # method to print desktop configuration
17
+ def print_desktop_configuration
18
+ puts 'Platform : ' + Selenium::WebDriver::Platform.os.to_s.upcase
19
+ puts 'Browser : ' + $driver.capabilities.browser_name.to_s.upcase + " " + $driver.capabilities.version.to_s
20
+ puts ''
21
+ end
22
+
23
+ # method to print mobile configuration
24
+ def print_mobile_configuration
25
+ puts "Platform : #{$platform.upcase}"
26
+ puts "OS version : #{$os_version}"
27
+ puts "Device : #{$device_name}"
28
+
29
+ if $app_path.nil?
30
+ puts 'Browser : ' + $driver.capabilities.browser_name.to_s.upcase + " " + $driver.capabilities.version.to_s
31
+ else
32
+ puts "App Tested : #{$app_path}"
33
+ end
34
+ puts ''
35
+ end
@@ -0,0 +1,87 @@
1
+ # Error handling methods
2
+
3
+ # Method to check browser type
4
+ def validate_parameters(platform, browser_type, app_path)
5
+ if platform == 'desktop'
6
+ if !%w(firefox internet_explorer chrome safari opera chrome_headless remote).include? browser_type
7
+ print_error_desktop
8
+ end
9
+ elsif platform == 'android'
10
+ print_error_android browser_type, app_path
11
+ elsif platform == 'iOS'
12
+ puts "Not Implemented..."
13
+ # print_error_ios browser_type, app_path
14
+ else
15
+ print_invalid_platform
16
+ end
17
+ end
18
+
19
+ # print error for desktop
20
+ def print_error_desktop
21
+ puts "\nInappropraite desktop browser : \"#{ENV['BROWSER']}\""
22
+ puts "\nUsage : cucumber BROWSER=browser_name"
23
+ puts "\nBrowser Supported :\n"
24
+ puts "\n1.internet_explorer\n2.chrome\n3.firefox\n4.safari\n5.opera\n6.chrome_headless\n7.remote"
25
+ Process.exit(0)
26
+ end
27
+
28
+ # print error for android
29
+ def print_error_android(browser_type, app_path)
30
+ if browser_type=='firefox' and app_path==nil
31
+ puts "\nOops... not mentioned \"Browser\" or \"App path\""
32
+ print_error_android_app
33
+ print_error_android_web
34
+ Process.exit(0)
35
+ elsif browser_type!='firefox' and !%w(native chrome).include? browser_type
36
+ puts "\nOops... not supported browser"
37
+ print_error_android_web
38
+ Process.exit(0)
39
+ end
40
+ end
41
+
42
+ # print error for android app
43
+ def print_error_android_app
44
+ puts "\nTo run test on android app"
45
+ puts "\n Usage : cucumber PLATFORM=android APP_PATH=path/to/app"
46
+ end
47
+
48
+ # print error for android web
49
+ def print_error_android_web
50
+ puts "\nTo run test on android mobile web"
51
+ puts "\n Usage : cucumber PLATFORM=android BROWSER=browser_name"
52
+ puts "\n Supported browsers are \"chrome\" and \"native\""
53
+ end
54
+
55
+ # print error for ios
56
+ def print_error_ios
57
+ if browser_type=='firefox' and app_path==nil
58
+ puts "\nOops... not mentioned \"Browser\" or \"App path\""
59
+ print_error_ios_app
60
+ print_error_ios_web
61
+ Process.exit(0)
62
+ elsif browser_type!='safari'
63
+ puts "\nOops... not supported browser"
64
+ print_error_ios_app_web
65
+ Process.exit(0)
66
+ end
67
+ end
68
+
69
+ # print error for ios app
70
+ def print_error_ios_app
71
+ puts "\nTo run test on iOS App"
72
+ puts "\n Usage : cucumber PLATFORM=iOS APP_PATH=path/to/app"
73
+ end
74
+
75
+ # print error for ios web
76
+ def print_error_ios_web
77
+ puts "\nTo run test on iOS mobile web"
78
+ puts "\n Usage : cucumber PLATFORM=iOS BROWSER=safari"
79
+ end
80
+
81
+ # print error if invalid platform
82
+ def print_invalid_platform
83
+ puts "\nOops... Invalid Platform"
84
+ puts "\nSupported platform are \"android\" and \"iOS\"."
85
+ puts "\nTo run on Desktop no need to mention platform."
86
+ Process.exit(0)
87
+ end
@@ -0,0 +1,69 @@
1
+ require_relative 'required_files'
2
+
3
+ # method to enter text into textfield
4
+ def enter_text(element, text)
5
+ foundElement = find_object(element)
6
+ WAIT.until { foundElement }.send_keys(text)
7
+ end
8
+
9
+ # method to clear text from textfield
10
+ def clear_text(element)
11
+ foundElement = find_object(element)
12
+ WAIT.until { foundElement }.clear
13
+ end
14
+
15
+ # method to select option from dropdwon list
16
+ def select_option_from_dropdown(element, by, option)
17
+ dropdown = WAIT.until { find_object(element) }
18
+ select_list = Selenium::WebDriver::Support::Select.new(dropdown)
19
+ select_list.select_by(:"#{by}", "#{option}")
20
+ end
21
+
22
+ # method to select all option from dropdwon list
23
+ def select_all_option_from_multiselect_dropdown(element)
24
+ dropdown = WAIT.until { find_object(element) }
25
+ select_list = Selenium::WebDriver::Support::Select.new(dropdown)
26
+ select_list.select_all
27
+ end
28
+
29
+ # method to unselect all option from dropdwon list
30
+ def unselect_all_option_from_multiselect_dropdown(element)
31
+ dropdown = WAIT.until { find_object(element) }
32
+ select_list = Selenium::WebDriver::Support::Select.new(dropdown)
33
+ select_list.deselect_all
34
+ end
35
+
36
+ # method to check checkbox
37
+ def check_checkbox(element)
38
+ checkbox = WAIT.until { find_object(element) }
39
+ checkbox.click unless checkbox.selected?
40
+ end
41
+
42
+ # method to uncheck checkbox
43
+ def uncheck_checkbox(element)
44
+ checkbox = WAIT.until { find_object(element) }
45
+
46
+ if checkbox.selected?
47
+ checkbox.click
48
+ end
49
+ end
50
+
51
+ # method to select radio button
52
+ def toggle_checkbox(element)
53
+ WAIT.until { find_object(element) }.click
54
+ end
55
+
56
+ # method to select radio button
57
+ def select_radio_button(element)
58
+ radio_button = WAIT.until { find_object(element) }
59
+ radio_button.click unless radio_button.selected?
60
+ end
61
+
62
+ # method to select option from radio button group
63
+ def select_option_from_radio_button_group(element, by, option)
64
+ radio_button_group = WAIT.until { find_object(element) }
65
+
66
+ getter = ->(rb, by) { by == 'value' ? rb.attribute('value') : rb.text }
67
+ ele = radio_button_group.find { |rb| getter.call(rb, by) == option }
68
+ ele.click unless ele.selected?
69
+ end
@@ -0,0 +1,9 @@
1
+ require_relative 'required_files'
2
+
3
+ def handle_alert(decesion)
4
+ if decesion == 'accept'
5
+ $driver.switch_to.alert.accept
6
+ else
7
+ $driver.switch_to.alert.dismiss
8
+ end
9
+ end
@@ -0,0 +1,47 @@
1
+
2
+ # custome exception class
3
+ class TestCaseFailed < Exception
4
+ end
5
+
6
+ # WAIT instance for explicit wait
7
+ WAIT = Selenium::WebDriver::Wait.new(:timeout => 30)
8
+
9
+ # method to validate locator
10
+ def valid_locator_type? type
11
+ %w(id class css name xpath).include? type
12
+ end
13
+
14
+ def validate_locator type
15
+ raise "Invalid locator type - #{type}" unless valid_locator_type? type
16
+ end
17
+
18
+ # method to validate dropdown selector
19
+ def valid_option_by? option_by
20
+ %w(text value index).include? option_by
21
+ end
22
+
23
+ def validate_option_by option_by
24
+ raise "Invalid option by - #{option_by}" unless valid_option_by? option_by
25
+ end
26
+
27
+ # Return android device name and android version using adb command
28
+ def get_device_info
29
+ IO.popen('adb shell getprop ro.product.brand') { |f| $device = f.gets.chomp.upcase}
30
+ $device += ' '
31
+ IO.popen('adb shell getprop ro.product.model') { |f| $device += f.gets.chomp.upcase}
32
+ IO.popen('adb shell getprop ro.build.version.release') { |f| $os_version = f.gets.chomp.upcase}
33
+ return $device, $os_version
34
+ end
35
+
36
+ def find_object(string_object)
37
+ string_object = string_object.gsub(/"/, "'")
38
+ hash_object = $OBJECT[string_object]
39
+ if hash_object == nil
40
+ raise "Object not found - Object: #{string_object} is not found in Object Repository."
41
+ end
42
+ locator_type = hash_object.keys.first.to_s
43
+ locator_value = hash_object[locator_type]
44
+ validate_locator(locator_type)
45
+ $driver.find_element(:"#{locator_type}" => "#{locator_value}")
46
+ end
47
+
@@ -0,0 +1,123 @@
1
+ require_relative 'required_files'
2
+
3
+ # method to open link
4
+ def navigate_to(link)
5
+ $driver.get link
6
+ end
7
+
8
+ # method to navigate back & forword
9
+ def navigate(direction)
10
+ if direction == 'back'
11
+ $driver.navigate.back
12
+ else
13
+ $driver.navigate.forward
14
+ end
15
+ end
16
+
17
+ # method to quite webdriver instance
18
+ def close_driver
19
+ $driver.quit
20
+ end
21
+
22
+ # method to return key by os wise
23
+ def get_key
24
+ os = Selenium::WebDriver::Platform.os
25
+ if os.to_s == 'windows'
26
+ return 'control'
27
+ elsif os.to_s == 'macosx'
28
+ return 'command'
29
+ else
30
+ raise 'Invalid OS'
31
+ end
32
+ end
33
+
34
+ # Method to zoom in/out page
35
+ def zoom_in_out(in_out)
36
+ $driver.action.key_down(:"#{get_key}").send_keys(:"#{in_out}").key_up(:"#{get_key}").perform
37
+ end
38
+
39
+ # Method to zoom in/out web page until web element displyas
40
+ def zoom_in_out_till_element_display(element, in_out)
41
+ while true
42
+ if WAIT.until { find_object(element) }.displayed?
43
+ break
44
+ else
45
+ $driver.action.key_down(:"#{get_key}").send_keys(:"#{in_out}").key_up(:"#{get_key}").perform
46
+ end
47
+ end
48
+ end
49
+
50
+ # Method to resize browser
51
+ def resize_browser(width, heigth)
52
+ $driver.manage.window.resize_to(width, heigth)
53
+ end
54
+
55
+ # Method to maximize browser
56
+ def maximize_browser
57
+ $driver.manage.window.maximize
58
+ end
59
+
60
+ # Method to refresh page
61
+ def refresh_page
62
+ $driver.navigate.refresh
63
+ end
64
+
65
+ # Method to hover on element
66
+ def hover_over_element(element)
67
+ element = WAIT.until { find_object(element) }
68
+ $driver.action.move_to(element).perform
69
+ end
70
+
71
+ # Method to scroll page to perticular element
72
+ def scroll_to_element(element)
73
+ ele_scroll = WAIT.until { find_object(element) }
74
+ ele_scroll.location_once_scrolled_into_view
75
+ end
76
+
77
+ # method to scroll page to top or end
78
+ def scroll_page(to)
79
+ if to == 'end'
80
+ $driver.execute_script('window.scrollTo(0,Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight));')
81
+ elsif to == 'top'
82
+ $driver.execute_script('window.scrollTo(Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight),0);')
83
+ else
84
+ raise "Exception : Invalid Direction (only scroll \"top\" or \"end\")"
85
+ end
86
+ end
87
+
88
+ $old_win = nil
89
+
90
+ # Method to switch to new window
91
+
92
+ def switch_to_new_window
93
+ $old_win = $driver.window_handle
94
+ $driver.switch_to.window($driver.window_handles[1])
95
+ end
96
+
97
+
98
+ # Method to switch to old window
99
+ def switch_to_old_window
100
+ $driver.switch_to.window($old_win)
101
+ end
102
+
103
+ # Method to close new window
104
+ def close_new_window
105
+ $driver.close
106
+ end
107
+
108
+ =begin
109
+ def switch_to_new_window
110
+ win_handles = $driver.window_handles
111
+
112
+ puts $driver.title
113
+ puts win_handles.length
114
+
115
+ $driver.switch_to.window($driver.window_handles[1])
116
+ puts $driver.window_handles[1]
117
+ puts $driver.title
118
+
119
+ $driver.switch_to.window($driver.window_handles[2])
120
+ puts $driver.window_handles[2]
121
+ puts $driver.title
122
+ end
123
+ =end
@@ -0,0 +1,15 @@
1
+ require_relative 'required_files'
2
+
3
+ def wait(time)
4
+ sleep time.to_i
5
+ end
6
+
7
+ def wait_for_element_to_display(element, duration)
8
+ wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i) # seconds
9
+ wait.until { find_object(element).displayed? }
10
+ end
11
+
12
+ def wait_for_element_to_enable(element, duration)
13
+ wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i) # seconds
14
+ wait.until { find_object(element).enabled? }
15
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'selenium-webdriver'
3
+ require 'open-uri'
4
+ require 'rbconfig'
5
+ require 'appium_lib_core'
6
+ include RbConfig
7
+
8
+ require_relative 'misc_methods'
9
+ require_relative 'error_handling_methods'
@@ -0,0 +1,6 @@
1
+ require_relative 'required_files'
2
+
3
+ def take_screenshot
4
+ cur_time = Time.now.strftime('%Y%m%d%H%M%S%L')
5
+ $driver.save_screenshot('./features/screenshots/screenshot' + cur_time + '.png')
6
+ end
@@ -0,0 +1,79 @@
1
+ # require 'cucumber'
2
+ # require_relative 'methods/navigate_methods'
3
+
4
+ # Then(/^I navigate to "([^\"]*)"$/)do |link|
5
+ # navigate_to(link)
6
+ # end
7
+
8
+ # Then(/^I navigate forward/) do
9
+ # navigate('forward')
10
+ # end
11
+
12
+ # Then(/^I navigate back/) do
13
+ # navigate('back')
14
+ # end
15
+
16
+ # Then(/^I close browser$/) do
17
+ # close_driver
18
+ # end
19
+
20
+ # # step to resize browser
21
+ # Then(/^I resize browser window size to width (\d+) and height (\d+)$/) do |width, heigth|
22
+ # resize_browser(width, heigth)
23
+ # end
24
+
25
+ # # step to maximize browser
26
+ # Then(/^I maximize browser window$/) do
27
+ # maximize_browser
28
+ # end
29
+
30
+ # # steps to refresh page
31
+ # Then(/^I refresh page$/) do
32
+ # refresh_page
33
+ # end
34
+
35
+ # Then(/^I switch to new window$/) do
36
+ # switch_to_new_window
37
+ # end
38
+
39
+ # Then(/^I switch to previous window$/) do
40
+ # switch_to_old_window
41
+ # end
42
+
43
+ # Then(/^I close new window$/) do
44
+ # close_new_window
45
+ # end
46
+
47
+ # # steps to scroll to element
48
+ # Then(/^I scroll to element "(.*?)"$/) do |type, element|
49
+ # scroll_to_element(type, element)
50
+ # end
51
+
52
+ # # steps to scroll web page to top or end
53
+ # Then(/^I scroll to (top|end) of page$/) do |to|
54
+ # scroll_page(to)
55
+ # end
56
+
57
+ # # step to hover over a element Note: Doesn't work on Windows firefox
58
+ # When(/^I hover over element having (.+) "(.*?)"$/) do |type, element|
59
+ # hover_over_element(type, element)
60
+ # end
61
+
62
+ # # steps to zoom in page
63
+ # Then(/^I zoom in page$/) do
64
+ # zoom_in_out('add')
65
+ # end
66
+
67
+ # # steps to zoom out page
68
+ # Then(/^I zoom out page$/) do
69
+ # zoom_in_out('subtract')
70
+ # end
71
+
72
+ # # steps to zoom out till element displays
73
+ # Then(/^I zoom out page till I see element "(.*?)"$/) do |type, element|
74
+ # zoom_in_out_till_element_display(type, 'subtract', element)
75
+ # end
76
+
77
+ # Then(/^I reset page view$/) do
78
+ # zoom_in_out('numpad0')
79
+ # end