itms_automation 2.5 → 2.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) 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 +106 -0
  30. data/example/desktop web/desktop_web_gmail_login/features/support/hooks.rb +38 -0
  31. data/{project → features-skeleton}/Gemfile +0 -0
  32. data/features-skeleton/Gemfile.lock +63 -0
  33. data/features-skeleton/README.md +132 -0
  34. data/{project → features-skeleton}/cucumber.yml +0 -0
  35. data/features-skeleton/my_first.feature +10 -0
  36. data/features-skeleton/screenshots/test.png +0 -0
  37. data/features-skeleton/step_definitions/custom_steps.rb +5 -0
  38. data/features-skeleton/step_definitions/repositories/project_object.yml +1 -0
  39. data/features-skeleton/support/env.rb +105 -0
  40. data/features-skeleton/support/hooks.rb +38 -0
  41. data/lib/itms_automation.rb +1 -3
  42. data/lib/itms_automation/assertion_steps.rb +68 -0
  43. data/lib/itms_automation/click_elements_steps.rb +24 -0
  44. data/lib/itms_automation/configuration_steps.rb +7 -0
  45. data/lib/itms_automation/input_steps.rb +59 -0
  46. data/lib/itms_automation/javascript_handling_steps.rb +10 -0
  47. data/lib/itms_automation/methods/assertion_methods.rb +333 -0
  48. data/lib/itms_automation/methods/click_elements_methods.rb +22 -0
  49. data/lib/itms_automation/methods/configuration_methods.rb +35 -0
  50. data/lib/itms_automation/methods/error_handling_methods.rb +93 -0
  51. data/lib/itms_automation/methods/input_methods.rb +69 -0
  52. data/lib/itms_automation/methods/javascript_handling_methods.rb +9 -0
  53. data/lib/itms_automation/methods/misc_methods.rb +63 -0
  54. data/lib/itms_automation/methods/navigate_methods.rb +123 -0
  55. data/lib/itms_automation/methods/progress_methods.rb +15 -0
  56. data/lib/itms_automation/methods/required_files.rb +9 -0
  57. data/lib/itms_automation/methods/screenshot_methods.rb +6 -0
  58. data/lib/itms_automation/navigation_steps.rb +79 -0
  59. data/lib/itms_automation/progress_steps.rb +17 -0
  60. data/lib/itms_automation/screenshot_steps.rb +6 -0
  61. data/lib/itms_automation/version.rb +5 -3
  62. metadata +89 -75
  63. data/bin/console +0 -14
  64. data/bin/documentation_generator.rb +0 -119
  65. data/bin/setup +0 -8
  66. data/lib/itms_automation/all_steps.rb +0 -8
  67. data/lib/itms_automation/assertion_helper.rb +0 -29
  68. data/lib/itms_automation/auto_util.rb +0 -707
  69. data/lib/itms_automation/database_steps_helper.rb +0 -125
  70. data/lib/itms_automation/web_steps_helper.rb +0 -867
  71. data/project/Gemfile.lock +0 -92
  72. data/project/README.md +0 -34
  73. data/project/Rakefile +0 -24
  74. data/project/features/TestSuite/WebGUI.feature +0 -5
  75. data/project/features/step_definitions/lib_steps/steps_definition.rb +0 -46
  76. data/project/features/step_definitions/repositories/project_object.yml +0 -26
  77. data/project/features/support/env.rb +0 -9
  78. data/project/features/support/hooks.rb +0 -122
@@ -0,0 +1,22 @@
1
+ require_relative 'required_files'
2
+
3
+ def click(element)
4
+ WAIT.until { find_object(element) }.click
5
+ end
6
+
7
+ def click_forcefully(element)
8
+ $driver.execute_script('arguments[0].click();', WAIT.until { find_object(element) })
9
+ end
10
+
11
+ def double_click(element)
12
+ found_element = WAIT.until { find_object(element) }
13
+ $driver.action.double_click(found_element).perform
14
+ end
15
+
16
+ def long_press( element, duration)
17
+ found_element = WAIT.until { find_object(element) }
18
+ parameters = { "element" => "#{found_element}", "duration" => "#{duration}" }
19
+ args = parameters.select { |k, v| [:element, :duration].include? k }
20
+ args = args_with_ele_ref(args)
21
+ chain_method(:longPress, args)
22
+ end
@@ -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,93 @@
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
88
+
89
+ def print_error_object_repository
90
+ puts "\nNo Object Repository found."
91
+ puts "\nPlease create file \"project_object.yml\" in path \"features/step_definitions/repositories/\""
92
+ Process.exit(0)
93
+ 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,63 @@
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
+ $OBJECT = load_object_repository
38
+ string_object = string_object.gsub(/"/, "'")
39
+ hash_object = $OBJECT[string_object]
40
+ if hash_object == nil
41
+ raise "Object not found - Object: #{string_object} is not found in Object Repository."
42
+ end
43
+ locator_type = hash_object.keys.first.to_s
44
+ locator_value = hash_object[locator_type]
45
+ validate_locator(locator_type)
46
+ $driver.find_element(:"#{locator_type}" => "#{locator_value}")
47
+ end
48
+
49
+ def load_object_repository
50
+ begin
51
+ loadYAMLfile("features/step_definitions/repositories/project_object.yml")
52
+ rescue => exception
53
+ print_error_object_repository
54
+ end
55
+ end
56
+
57
+ def loadYAMLfile(filename)
58
+ begin
59
+ return YAML.load_file(filename)
60
+ rescue Psych::SyntaxError => ex
61
+ raise "❌ SyntaxError when reading file: #{ex}"
62
+ end
63
+ end
@@ -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'