itms_automation 2.5.6 → 2.5.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 583b36e2ec92b94f520492dc60d2e6664b258f37033c793a6b5898aabca7685b
4
- data.tar.gz: ee00d5a2d671302e486317afbd252014a12ef04ed64fe707ec5cf2ba166fc9ce
3
+ metadata.gz: 03c38ca27fff8e41d5bc25a5f98019cbf4e4cc90f1be655b0264b2da1301a2f7
4
+ data.tar.gz: 6ef0427780ea0b6cfade74682e8d60529fa7194bea56b56546fd786034871bf1
5
5
  SHA512:
6
- metadata.gz: 50903bb26b4a64cac5b3fe53e14851de2917462605d52eba2e54c8ebfc9a2146440be7bb3f85ee7f61a7b099c395d0b44a5920cfede8a153f2f5323ac992d397
7
- data.tar.gz: 6aaf390948a96cbb711e3a04e14e9002ec3c3dc2c26457ceaa8fc4a790d977cd95cd1123b36b6ff830b145a36c3d873982bc32e2f8d7a9924764ada53dce56e1
6
+ metadata.gz: 5e4d5042bb36effd440cda7b75e0ea9547a3b5039b6b360fe77d940113480fb82fa5bff6ed3719177c2489f8fd4d6d1e43c48db00562f766a5552b5a01025f69
7
+ data.tar.gz: 4ac9c825eb5584fece56a3106430de1991c439cdbf4040afe8028091dfb5d2555d8cc03caac65a323fc30b88df8ea66451ebacb8257407f5381b198f761ae5f3
@@ -1,8 +1,10 @@
1
1
  require 'rubygems'
2
- require 'itms_automation'
3
-
2
+ # require 'itms_automation'
3
+ require_relative '../../../lib/itms_automation.rb'
4
+ # require 'appium_lib'
5
+ require 'appium_lib_core'
4
6
  # Store command line arguments
5
- $browser_type = ENV['BROWSER'] || 'ff'
7
+ $browser_type = ENV['BROWSER'] || 'firefox'
6
8
  $platform = ENV['PLATFORM'] || 'desktop'
7
9
  $os_version = ENV['OS_VERSION']
8
10
  $device_name = ENV['DEVICE_NAME']
@@ -23,29 +25,82 @@ if $platform == 'android' or $platform == 'iOS'
23
25
  $device_name, $os_version = get_device_info
24
26
  end
25
27
 
26
- desired_caps = {
27
- caps: {
28
- platformName: $platform,
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,
29
53
  browserName: $browser_type,
30
- versionNumber: $os_version,
31
54
  deviceName: $device_name,
32
- udid: $udid,
33
- app: ".//#{$app_path}"
34
- },
55
+ versionNumber: $os_version,
56
+ app: "WikipediaSample.apk"
57
+ },
58
+ appium_lib: {
59
+ wait: 30
35
60
  }
61
+ }
36
62
 
37
63
  begin
38
- $driver = Appium::Driver.new(desired_caps).start_driver
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
+
39
70
  rescue Exception => e
40
71
  puts e.message
41
72
  Process.exit(0)
42
73
  end
43
74
  else # else create driver instance for desktop browser
44
75
  begin
45
- $driver = Selenium::WebDriver.for(:"#{$browser_type}")
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
46
99
  $driver.manage().window().maximize()
100
+ p "session_id: #{$driver.session_id}"
47
101
  rescue Exception => e
48
102
  puts e.message
49
103
  Process.exit(0)
50
104
  end
51
105
  end
106
+
@@ -1,26 +1,38 @@
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.
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
15
10
  end
16
11
 
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.
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
25
37
  end
26
38
  end
@@ -93,9 +93,11 @@ else # else create driver instance for desktop browser
93
93
  Selenium::WebDriver.for(:firefox)
94
94
  end
95
95
  $driver.manage().window().maximize()
96
- p "session_id: #{$driver.session_id}"
97
96
  if ENV["UPDATE_SESSION_ID_API"]
98
- HTTParty.post(ENV["UPDATE_SESSION_ID_API"], body: { session_id: $driver.session_id })
97
+ begin
98
+ HTTParty.post(ENV["UPDATE_SESSION_ID_API"], body: { session_id: $driver.session_id })
99
+ rescue => exception
100
+ end
99
101
  end
100
102
  rescue Exception => e
101
103
  puts e.message
@@ -1,43 +1,3 @@
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
-
28
-
29
- AfterConfiguration do
30
- $OBJECT = loadYAMLfile("features/step_definitions/repositories/project_object.yml")
31
- end
32
-
33
- def loadYAMLfile(filename)
34
- begin
35
- return YAML.load_file(filename)
36
- rescue Psych::SyntaxError => ex
37
- raise "❌ SyntaxError when reading file: #{ex}"
38
- end
39
- end
40
-
41
1
  def validate_params_exist
42
2
  raise "❌ ERROR: Missing param SERVER_URL." if ENV['SERVER_URL'].nil?
43
3
  raise "❌ ERROR: Missing param BROWSER." if ENV['BROWSER'].nil?
@@ -50,6 +10,8 @@ def validate_params_exist
50
10
  end
51
11
 
52
12
  at_exit do
13
+ # quite driver
14
+ $driver.close()
53
15
  if ENV['REPORT']
54
16
  begin
55
17
  # validateReport
@@ -68,7 +30,9 @@ at_exit do
68
30
  end
69
31
  options = { report_title: "INFODation - Test Management System" }
70
32
  ReportBuilder.build_report options
71
- rescue NoMethodError
33
+ rescue Exception => e
34
+ puts e.message
35
+ Process.exit( 0 )
72
36
  end
73
37
  end
74
38
  end
@@ -41,17 +41,15 @@ def check_partial_title(partial_text_title, test_case)
41
41
  end
42
42
 
43
43
  # Method to get element text
44
- # param 1 : String : Locator type (id, name, class, xpath, css)
45
- # param 2 : String : Locator value
44
+ # param : String
46
45
  def get_element_text(element)
47
46
  WAIT.until { find_object(element) }.text
48
47
  end
49
48
 
50
49
  # Method to check element text
51
- # param 1 : String : Locator type (id, name, class, xpath, css)
50
+ # param 1 : String : Element
52
51
  # param 2 : String : Expected element text
53
- # param 3 : String : Locator value
54
- # param 4 : Boolean : test case [true or flase]
52
+ # param 3 : Boolean : test case [true or flase]
55
53
  def check_element_text(element, actual_value, test_case)
56
54
  element_text = get_element_text(element)
57
55
 
@@ -67,10 +65,9 @@ def check_element_text(element, actual_value, test_case)
67
65
  end
68
66
 
69
67
  # Method to check partial element text
70
- # param 1 : String : Locator type (id, name, class, xpath, css)
68
+ # param 1 : String : Element
71
69
  # param 2 : String : Expected element partial text
72
- # param 3 : String : Locator value
73
- # param 4 : Boolean : test case [true or flase]
70
+ # param 3 : Boolean : test case [true or flase]
74
71
  def check_element_partial_text(element, actual_value, test_case)
75
72
  element_text = get_element_text(element)
76
73
 
@@ -86,16 +83,14 @@ def check_element_partial_text(element, actual_value, test_case)
86
83
  end
87
84
 
88
85
  # Method to return element status - enabled?
89
- # param 1 : String : Locator type (id, name, class, xpath, css)
90
- # param 2 : String : Locator value
86
+ # param : String : Element
91
87
  def is_element_enabled(element)
92
88
  WAIT.until{ find_object(element) }.enabled?
93
89
  end
94
90
 
95
91
  # Element enabled checking
96
- # param 1 : String : Locator type (id, name, class, xpath, css)
97
- # param 2 : String : Expected element text
98
- # param 4 : Boolean : test case [true or flase]
92
+ # param 1 : String : Element
93
+ # param 2 : Boolean : test case [true or flase]
99
94
  def check_element_enable(element, test_case)
100
95
  result = is_element_enabled(element)
101
96
 
@@ -107,19 +102,17 @@ def check_element_enable(element, test_case)
107
102
  end
108
103
 
109
104
  # method to get attribute value
110
- # param 1 : String : Locator type (id, name, class, xpath, css)
111
- # param 2 : String : Expected element text
112
- # param 3 : String : atrribute name
105
+ # param 1 : String : Element
106
+ # param 2 : String : atrribute name
113
107
  def get_element_attribute(element, attribute_name)
114
108
  WAIT.until{ find_object(element) }.attribute("#{attribute_name}")
115
109
  end
116
110
 
117
111
  # method to check attribute value
118
- # param 1 : String : Locator type (id, name, class, xpath, css)
112
+ # param 1 : String : Element
119
113
  # param 2 : String : atrribute name
120
114
  # param 3 : String : atrribute value
121
- # param 4 : String : Locator value
122
- # param 5 : Boolean : test case [true or flase]
115
+ # param 4 : Boolean : test case [true or flase]
123
116
  def check_element_attribute(element, attribute_name, attribute_value, test_case)
124
117
 
125
118
  attr_val = get_element_attribute(element, attribute_name)
@@ -136,16 +129,14 @@ def check_element_attribute(element, attribute_name, attribute_value, test_case)
136
129
  end
137
130
 
138
131
  # method to get element status - displayed?
139
- # param 1 : String : Locator type (id, name, class, xpath, css)
140
- # param 2 : String : Locator value
141
- def is_element_displayed(access_type, access_name)
132
+ # param : String : Element
133
+ def is_element_displayed(element)
142
134
  WAIT.until{ find_object(element) }.displayed?
143
135
  end
144
136
 
145
137
  # method to check element presence
146
- # param 1 : String : Locator type (id, name, class, xpath, css)
147
- # param 2 : String : Locator value
148
- # param 3 : Boolean : test case [true or flase]
138
+ # param 1 : String : Element
139
+ # param 2 : Boolean : test case [true or flase]
149
140
  def check_element_presence(element, test_case)
150
141
  if test_case
151
142
  if !is_element_displayed(element)
@@ -165,9 +156,8 @@ def check_element_presence(element, test_case)
165
156
  end
166
157
 
167
158
  # method to assert checkbox check/uncheck
168
- # param 1 : String : Locator type (id, name, class, xpath, css)
169
- # param 2 : String : Locator value
170
- # param 3 : Boolean : test case [true or flase]
159
+ # param 1 : String : Element
160
+ # param 2 : Boolean : test case [true or flase]
171
161
  def is_checkbox_checked(element, should_be_checked = true)
172
162
  checkbox = WAIT.until{ find_object(element) }
173
163
 
@@ -179,9 +169,8 @@ def is_checkbox_checked(element, should_be_checked = true)
179
169
  end
180
170
 
181
171
  # method to assert radio button selected/unselected
182
- # param 1 : String : Locator type (id, name, class, xpath, css)
183
- # param 2 : String : Locator value
184
- # param 3 : Boolean : test case [true or flase]
172
+ # param 1 : String : Element
173
+ # param 2 : Boolean : test case [true or flase]
185
174
  def is_radio_button_selected(element, should_be_selected = true)
186
175
  radio_button = WAIT.until{ find_object(element) }
187
176
 
@@ -8,15 +8,15 @@ def click_forcefully(element)
8
8
  $driver.execute_script('arguments[0].click();', WAIT.until { find_object(element) })
9
9
  end
10
10
 
11
- def double_click(access_type, access_value)
12
- element = WAIT.until { find_object(element) }
13
- $driver.action.double_click(element).perform
11
+ def double_click(element)
12
+ found_element = WAIT.until { find_object(element) }
13
+ $driver.action.double_click(found_element).perform
14
14
  end
15
15
 
16
16
 
17
- def long_press( access_name, duration)
18
- element = WAIT.until { find_object(access_name) }
19
- parameters = { "element" => "#{element}", "duration" => "#{duration}" }
17
+ def long_press( element, duration)
18
+ found_element = WAIT.until { find_object(element) }
19
+ parameters = { "element" => "#{found_element}", "duration" => "#{duration}" }
20
20
  args = parameters.select { |k, v| [:element, :duration].include? k }
21
21
  args = args_with_ele_ref(args)
22
22
  chain_method(:longPress, args)
@@ -85,3 +85,9 @@ def print_invalid_platform
85
85
  puts "\nTo run on Desktop no need to mention platform."
86
86
  Process.exit(0)
87
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
@@ -34,6 +34,7 @@ def get_device_info
34
34
  end
35
35
 
36
36
  def find_object(string_object)
37
+ $OBJECT = load_object_repository
37
38
  string_object = string_object.gsub(/"/, "'")
38
39
  hash_object = $OBJECT[string_object]
39
40
  if hash_object == nil
@@ -45,3 +46,18 @@ def find_object(string_object)
45
46
  $driver.find_element(:"#{locator_type}" => "#{locator_value}")
46
47
  end
47
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
@@ -1,5 +1,5 @@
1
1
  module ITMS
2
2
  module Automation
3
- VERSION = '2.5.6'
3
+ VERSION = '2.5.7'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itms_automation
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.6
4
+ version: 2.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - INFOdation
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-14 00:00:00.000000000 Z
11
+ date: 2020-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: 3.1.2
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 1.3.18
22
+ version: 3.1.2
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: '1.3'
29
+ version: 3.1.2
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 1.3.18
32
+ version: 3.1.2
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: selenium-webdriver
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -130,6 +130,7 @@ files:
130
130
  - features-skeleton/my_first.feature
131
131
  - features-skeleton/screenshots/test.png
132
132
  - features-skeleton/step_definitions/custom_steps.rb
133
+ - features-skeleton/step_definitions/repositories/project_object.yml
133
134
  - features-skeleton/support/env.rb
134
135
  - features-skeleton/support/hooks.rb
135
136
  - lib/itms_automation.rb