itms_automation 2.3 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) 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/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/step_definitions/repositories/project_object.yml +1 -0
  35. data/features-skeleton/support/env.rb +108 -0
  36. data/features-skeleton/support/hooks.rb +38 -0
  37. data/lib/itms_automation.rb +1 -3
  38. data/lib/itms_automation/assertion_steps.rb +68 -0
  39. data/lib/itms_automation/click_elements_steps.rb +24 -0
  40. data/lib/itms_automation/configuration_steps.rb +7 -0
  41. data/lib/itms_automation/input_steps.rb +59 -0
  42. data/lib/itms_automation/javascript_handling_steps.rb +10 -0
  43. data/lib/itms_automation/methods/assertion_methods.rb +333 -0
  44. data/lib/itms_automation/methods/click_elements_methods.rb +23 -0
  45. data/lib/itms_automation/methods/configuration_methods.rb +35 -0
  46. data/lib/itms_automation/methods/error_handling_methods.rb +93 -0
  47. data/lib/itms_automation/methods/input_methods.rb +69 -0
  48. data/lib/itms_automation/methods/javascript_handling_methods.rb +9 -0
  49. data/lib/itms_automation/methods/misc_methods.rb +63 -0
  50. data/lib/itms_automation/methods/navigate_methods.rb +123 -0
  51. data/lib/itms_automation/methods/progress_methods.rb +15 -0
  52. data/lib/itms_automation/methods/required_files.rb +9 -0
  53. data/lib/itms_automation/methods/screenshot_methods.rb +6 -0
  54. data/lib/itms_automation/navigation_steps.rb +79 -0
  55. data/lib/itms_automation/progress_steps.rb +17 -0
  56. data/lib/itms_automation/screenshot_steps.rb +6 -0
  57. data/lib/itms_automation/version.rb +5 -3
  58. metadata +93 -90
  59. data/bin/console +0 -14
  60. data/bin/documentation_generator.rb +0 -119
  61. data/bin/setup +0 -8
  62. data/lib/itms_automation/all_steps.rb +0 -8
  63. data/lib/itms_automation/assertion_helper.rb +0 -29
  64. data/lib/itms_automation/auto_util.rb +0 -702
  65. data/lib/itms_automation/database_steps_helper.rb +0 -125
  66. data/lib/itms_automation/web_steps_helper.rb +0 -844
  67. data/project/Gemfile +0 -3
  68. data/project/Gemfile.lock +0 -92
  69. data/project/README.md +0 -34
  70. data/project/Rakefile +0 -24
  71. data/project/config/chrome_headless_options.yaml +0 -1
  72. data/project/config/chrome_options.yaml +0 -6
  73. data/project/config/firefox_headless_options.yaml +0 -1
  74. data/project/config/firefox_options.yaml +0 -1
  75. data/project/config/ie_options.yaml +0 -1
  76. data/project/config/remote_options.yaml +0 -6
  77. data/project/config/safari_options.yaml +0 -1
  78. data/project/cucumber.yml +0 -4
  79. data/project/features/TestSuite/WebGUI.feature +0 -5
  80. data/project/features/step_definitions/lib_steps/steps_definition.rb +0 -46
  81. data/project/features/step_definitions/repositories/project_object.yml +0 -26
  82. data/project/features/support/env.rb +0 -9
  83. data/project/features/support/hooks.rb +0 -128
@@ -0,0 +1,12 @@
1
+ Feature: Gmail Login mobile web
2
+
3
+ Scenario: valid credentials login
4
+ Given I navigate to "http://www.gmail.com"
5
+ Then I wait for 5 sec
6
+ Then I enter "your_email" into input field having id "Email"
7
+ Then I enter "your_password" into input field having id "Passwd"
8
+ When I click on element having id "signIn"
9
+ And I wait for 10 sec
10
+ Then element having xpath "//*[@id='tltbt']/div[3]/div/div" should be present
11
+ And I wait for 5 sec
12
+ Then I close browser
@@ -0,0 +1,5 @@
1
+ require 'itms_automation'
2
+
3
+ # Do Not Remove This File
4
+ # Add your custom steps here
5
+ # $driver is instance of webdriver use this instance to write your custom code
@@ -0,0 +1,51 @@
1
+ require 'rubygems'
2
+ require 'itms_automation'
3
+
4
+ # Store command line arguments
5
+ $browser_type = ENV['BROWSER'] || 'ff'
6
+ $platform = ENV['PLATFORM'] || 'desktop'
7
+ $os_version = ENV['OS_VERSION']
8
+ $device_name = ENV['DEVICE_NAME']
9
+ $udid = ENV['UDID']
10
+ $app_path = ENV['APP_PATH']
11
+
12
+ # check for valid parameters
13
+ validate_parameters $platform, $browser_type, $app_path
14
+
15
+ # If platform is android or ios create driver instance for mobile browser
16
+ if $platform == 'android' or $platform == 'iOS'
17
+
18
+ if $browser_type == 'native'
19
+ $browser_type = "Browser"
20
+ end
21
+
22
+ if $platform == 'android'
23
+ $device_name, $os_version = get_device_info
24
+ end
25
+
26
+ desired_caps = {
27
+ caps: {
28
+ platformName: $platform,
29
+ browserName: $browser_type,
30
+ versionNumber: $os_version,
31
+ deviceName: $device_name,
32
+ udid: $udid,
33
+ app: ".//#{$app_path}"
34
+ },
35
+ }
36
+
37
+ begin
38
+ $driver = Appium::Driver.new(desired_caps).start_driver
39
+ rescue Exception => e
40
+ puts e.message
41
+ Process.exit(0)
42
+ end
43
+ else # else create driver instance for desktop browser
44
+ begin
45
+ $driver = Selenium::WebDriver.for(:"#{$browser_type}")
46
+ $driver.manage().window().maximize()
47
+ rescue Exception => e
48
+ puts e.message
49
+ Process.exit(0)
50
+ end
51
+ end
@@ -0,0 +1,27 @@
1
+ #Cucumber provides a number of hooks which allow us to run blocks at various points in the Cucumber test cycle
2
+
3
+ Before do
4
+ # Do something before each scenario.
5
+ end
6
+
7
+ Before do |scenario|
8
+ # The +scenario+ argument is optional, but if you use it, you can get the title,
9
+ # description, or name (title + description) of the scenario that is about to be
10
+ # executed.
11
+ end
12
+
13
+ After do
14
+ # Do something after each scenario.
15
+ end
16
+
17
+ After do |scenario|
18
+ # Do something after each scenario.
19
+ # The +scenario+ argument is optional, but
20
+ # if you use it, you can inspect status with
21
+ # the #failed?, #passed? and #exception methods.
22
+
23
+ if(scenario.failed?)
24
+ #Do something if scenario fails.
25
+ end
26
+ end
27
+
@@ -0,0 +1,9 @@
1
+ Feature: Gmail_login
2
+
3
+ Scenario: Valid_gmail_login
4
+ Given I navigate to "http://www.gmail.com"
5
+ And I enter "abc@gmail.com" into input field having id "Email"
6
+ And I enter "!password*" into input field having id "Passwd"
7
+ When I click on element having id "signIn"
8
+ And I wait for 10 sec
9
+ Then I close browser
@@ -0,0 +1,21 @@
1
+ Feature: Gmail_login
2
+
3
+ Scenario: Open gmail
4
+ Given I navigate to "http://www.gmail.com"
5
+
6
+ Scenario Outline: In-valid Login
7
+ Then I clear input field having id "Email"
8
+ And I enter <username> into input field having id "Email"
9
+ Then I clear input field having id "Passwd"
10
+ And I enter <password> into input field having id "Passwd"
11
+ When I click on element having id "signIn"
12
+ Then element having id "errormsg_0_Passwd" should be present
13
+
14
+ Examples:
15
+ | username | password |
16
+ |"test1" |"password1" |
17
+ |"test2" |"password2" |
18
+ |"test3" |"password3" |
19
+
20
+ Scenario: close gmail
21
+ Then I close browser
@@ -0,0 +1,5 @@
1
+ require 'itms_automation'
2
+
3
+ # Do Not Remove This File
4
+ # Add your custom steps here
5
+ # $driver is instance of webdriver use this instance to write your custom code
@@ -0,0 +1,106 @@
1
+ require 'rubygems'
2
+ # require 'itms_automation'
3
+ require_relative '../../../lib/itms_automation.rb'
4
+ # require 'appium_lib'
5
+ require 'appium_lib_core'
6
+ # Store command line arguments
7
+ $browser_type = ENV['BROWSER'] || 'firefox'
8
+ $platform = ENV['PLATFORM'] || 'desktop'
9
+ $os_version = ENV['OS_VERSION']
10
+ $device_name = ENV['DEVICE_NAME']
11
+ $udid = ENV['UDID']
12
+ $app_path = ENV['APP_PATH']
13
+
14
+ # check for valid parameters
15
+ validate_parameters $platform, $browser_type, $app_path
16
+
17
+ # If platform is android or ios create driver instance for mobile browser
18
+ if $platform == 'android' or $platform == 'iOS'
19
+
20
+ if $browser_type == 'native'
21
+ $browser_type = "Browser"
22
+ end
23
+
24
+ if $platform == 'android'
25
+ $device_name, $os_version = get_device_info
26
+ end
27
+
28
+ # desired_caps = {
29
+ # caps: {
30
+ # platformName: $platform,
31
+ # browserName: $browser_type,
32
+ # versionNumber: $os_version,
33
+ # deviceName: $device_name,
34
+ # udid: $udid,
35
+ # app: ".//#{$app_path}"
36
+ # }
37
+ # }
38
+ # appium_url = 'http://localhost:4723/wd/hub'
39
+ # opts = {
40
+ # desired_capabilities: { # or { caps: {....} }
41
+ # platformName: :android,
42
+ # deviceName: 'Android Simulator',
43
+ # app: "WikipediaSample.apk"
44
+ # },
45
+ # appium_lib: {
46
+ # wait: 30
47
+ # }
48
+ # }
49
+
50
+ opts = {
51
+ desired_capabilities: { # or { caps: {....} }
52
+ platformName: $platform,
53
+ browserName: $browser_type,
54
+ deviceName: $device_name,
55
+ versionNumber: $os_version,
56
+ app: "WikipediaSample.apk"
57
+ },
58
+ appium_lib: {
59
+ wait: 30
60
+ }
61
+ }
62
+
63
+ begin
64
+ # $driver = Appium::Driver.new(desired_caps, url: appium_url).start_driver
65
+
66
+ # $driver = Selenium::WebDriver.for(:remote, :url => appium_url, :desired_capabilities => desired_caps)
67
+ @core = Appium::Core.for(opts) # create a core driver with `opts`
68
+ $driver = @core.start_driver
69
+
70
+ rescue Exception => e
71
+ puts e.message
72
+ Process.exit(0)
73
+ end
74
+ else # else create driver instance for desktop browser
75
+ begin
76
+ $driver = case $browser_type
77
+ when "chrome"
78
+ Selenium::WebDriver.for(:chrome)
79
+ when "safari"
80
+ Selenium::WebDriver.for(:safari)
81
+ when "internet_explorer"
82
+ Selenium::WebDriver.for(:internet_explorer)
83
+ when "chrome_headless"
84
+ Selenium::WebDriver.for(:chrome, :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: { args: %w(headless) }))
85
+ when "remote"
86
+ if ENV['SERVER_URL'].nil? || ENV['REMOTE_BROWSER'].nil?
87
+ puts "\nMissing SERVER_URL : SERVER_URL=http//SERVER_URL:4444/wd/hub"
88
+ puts "\nMissing REMOTE_BROWSER: REMOTE_BROWSER=browser_name"
89
+ Process.exit(0)
90
+ else
91
+ caps = Selenium::WebDriver::Remote::Capabilities.new
92
+ caps["browserName"] = ENV['REMOTE_BROWSER']
93
+ Selenium::WebDriver.for(:remote, :url => ENV['SERVER_URL'], :desired_capabilities => caps)
94
+ end
95
+
96
+ else
97
+ Selenium::WebDriver.for(:firefox)
98
+ end
99
+ $driver.manage().window().maximize()
100
+ p "session_id: #{$driver.session_id}"
101
+ rescue Exception => e
102
+ puts e.message
103
+ Process.exit(0)
104
+ end
105
+ end
106
+
@@ -0,0 +1,38 @@
1
+ def validate_params_exist
2
+ raise "❌ ERROR: Missing param SERVER_URL." if ENV['SERVER_URL'].nil?
3
+ raise "❌ ERROR: Missing param BROWSER." if ENV['BROWSER'].nil?
4
+ if ENV['REPORT']
5
+ raise "❌ ERROR: Missing param TESTSUITE." if ENV['TESTSUITE'].nil?
6
+ raise "❌ ERROR: Missing param TESTCASE_REPORT_NAME." if ENV['TESTCASE_REPORT_NAME'].nil?
7
+ $report_path = "Reports/#{ENV['TESTSUITE']}"
8
+ $testcase_report_name = ENV['TESTCASE_REPORT_NAME']
9
+ end
10
+ end
11
+
12
+ at_exit do
13
+ # quite driver
14
+ $driver.close()
15
+ if ENV['REPORT']
16
+ begin
17
+ # validateReport
18
+ time = Time.now.getutc
19
+ ReportBuilder.configure do |config|
20
+ config.report_path = "#{$report_path}/#{$testcase_report_name}"
21
+ config.input_path = "#{$report_path}/#{$testcase_report_name}.json"
22
+ config.report_types = [:json, :html]
23
+ config.color = 'blue'
24
+ config.additional_info = {
25
+ 'Browser' => $browser_type,
26
+ 'Platform' => $platform ,
27
+ 'OS Version' => $os_version,
28
+ 'Report Generated' => time
29
+ }
30
+ end
31
+ options = { report_title: "INFODation - Test Management System" }
32
+ ReportBuilder.build_report options
33
+ rescue Exception => e
34
+ puts e.message
35
+ Process.exit( 0 )
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,5 @@
1
+ Feature: Login feature
2
+
3
+ Scenario: As a valid user I can log into my web app
4
+ When I press "Login"
5
+ Then I see "Welcome to coolest web app ever"
@@ -0,0 +1,5 @@
1
+ require 'itms_automation'
2
+
3
+ # Do Not Remove This File
4
+ # Add your custom steps here
5
+ # $driver is instance of webdriver use this instance to write your custom code
@@ -0,0 +1,108 @@
1
+ require "rubygems"
2
+ require "itms_automation"
3
+ require "httparty"
4
+ require "cucumber"
5
+ require "report_builder"
6
+ require "selenium-webdriver"
7
+
8
+ $browser_type = ENV["BROWSER"] || "firefox"
9
+ $platform = ENV["PLATFORM"] || "desktop"
10
+ $os_version = ENV["OS_VERSION"]
11
+ $device_name = ENV["DEVICE_NAME"]
12
+ $udid = ENV["UDID"]
13
+ $app_path = ENV["APP_PATH"]
14
+
15
+ # check for valid parameters
16
+ validate_parameters $platform, $browser_type, $app_path
17
+
18
+ # If platform is android or ios create driver instance for mobile browser
19
+ if $platform == "android" or $platform == "iOS"
20
+ if $browser_type == "native"
21
+ $browser_type = "Browser"
22
+ end
23
+
24
+ if $platform == "android"
25
+ $device_name, $os_version = get_device_info
26
+ end
27
+
28
+ # desired_caps = {
29
+ # caps: {
30
+ # platformName: $platform,
31
+ # browserName: $browser_type,
32
+ # versionNumber: $os_version,
33
+ # deviceName: $device_name,
34
+ # udid: $udid,
35
+ # app: ".//#{$app_path}"
36
+ # }
37
+ # }
38
+ # appium_url = 'http://localhost:4723/wd/hub'
39
+ # opts = {
40
+ # desired_capabilities: { # or { caps: {....} }
41
+ # platformName: :android,
42
+ # deviceName: 'Android Simulator',
43
+ # app: "WikipediaSample.apk"
44
+ # },
45
+ # appium_lib: {
46
+ # wait: 30
47
+ # }
48
+ # }
49
+
50
+ opts = {
51
+ desired_capabilities: { # or { caps: {....} }
52
+ platformName: $platform,
53
+ browserName: $browser_type,
54
+ deviceName: $device_name,
55
+ versionNumber: $os_version,
56
+ app: "WikipediaSample.apk",
57
+ },
58
+ appium_lib: {
59
+ wait: 30,
60
+ },
61
+ }
62
+
63
+ begin
64
+ # $driver = Appium::Driver.new(desired_caps, url: appium_url).start_driver
65
+
66
+ # $driver = Selenium::WebDriver.for(:remote, :url => appium_url, :desired_capabilities => desired_caps)
67
+ @core = Appium::Core.for(opts) # create a core driver with `opts`
68
+ $driver = @core.start_driver
69
+ rescue Exception => e
70
+ puts e.message
71
+ Process.exit(0)
72
+ end
73
+ else # else create driver instance for desktop browser
74
+ begin
75
+ $driver = case $browser_type
76
+ when "chrome"
77
+ Selenium::WebDriver.for(:chrome)
78
+ when "safari"
79
+ Selenium::WebDriver.for(:safari)
80
+ when "internet_explorer"
81
+ Selenium::WebDriver.for(:internet_explorer)
82
+ when "chrome_headless"
83
+ Selenium::WebDriver.for(:chrome, :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: { args: %w(headless) }))
84
+ when "remote"
85
+ if ENV["SERVER_URL"].nil? || ENV["REMOTE_BROWSER"].nil?
86
+ puts "\nMissing SERVER_URL : SERVER_URL=http//SERVER_URL:4444/wd/hub"
87
+ puts "\nMissing REMOTE_BROWSER: REMOTE_BROWSER=browser_name"
88
+ Process.exit(0)
89
+ else
90
+ caps = Selenium::WebDriver::Remote::Capabilities.new
91
+ caps["browserName"] = ENV["REMOTE_BROWSER"]
92
+ Selenium::WebDriver.for(:remote, :url => ENV["SERVER_URL"], :desired_capabilities => caps)
93
+ end
94
+ else
95
+ Selenium::WebDriver.for(:firefox)
96
+ end
97
+ $driver.manage().window().maximize()
98
+ if ENV["UPDATE_SESSION_ID_API"]
99
+ begin
100
+ HTTParty.post(ENV["UPDATE_SESSION_ID_API"], body: { session_id: $driver.session_id })
101
+ rescue => exception
102
+ end
103
+ end
104
+ rescue Exception => e
105
+ puts e.message
106
+ Process.exit(0)
107
+ end
108
+ end
@@ -0,0 +1,38 @@
1
+ def validate_params_exist
2
+ raise "❌ ERROR: Missing param SERVER_URL." if ENV['SERVER_URL'].nil?
3
+ raise "❌ ERROR: Missing param BROWSER." if ENV['BROWSER'].nil?
4
+ if ENV['REPORT']
5
+ raise "❌ ERROR: Missing param TESTSUITE." if ENV['TESTSUITE'].nil?
6
+ raise "❌ ERROR: Missing param TESTCASE_REPORT_NAME." if ENV['TESTCASE_REPORT_NAME'].nil?
7
+ $report_path = "Reports/#{ENV['TESTSUITE']}"
8
+ $testcase_report_name = ENV['TESTCASE_REPORT_NAME']
9
+ end
10
+ end
11
+
12
+ at_exit do
13
+ # quite driver
14
+ $driver.close()
15
+ if ENV['REPORT']
16
+ begin
17
+ # validateReport
18
+ time = Time.now.getutc
19
+ ReportBuilder.configure do |config|
20
+ config.report_path = "#{$report_path}/#{$testcase_report_name}"
21
+ config.input_path = "#{$report_path}/#{$testcase_report_name}.json"
22
+ config.report_types = [:json, :html]
23
+ config.color = 'blue'
24
+ config.additional_info = {
25
+ 'Browser' => $browser_type,
26
+ 'Platform' => $platform ,
27
+ 'OS Version' => $os_version,
28
+ 'Report Generated' => time
29
+ }
30
+ end
31
+ options = { report_title: "INFODation - Test Management System" }
32
+ ReportBuilder.build_report options
33
+ rescue Exception => e
34
+ puts e.message
35
+ Process.exit( 0 )
36
+ end
37
+ end
38
+ end