itms_automation 2.7.1 → 2.7.6

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: '090afc5cfe29b875d3816ad9ca3e64c140c8b73a5fe2a7129d02b1641baa8d4f'
4
- data.tar.gz: 9f36d46924317a25e1474668a4b22b19d487a155f2c24508310ee81230548196
3
+ metadata.gz: 1d59d0694d3201fa93f0ea8fdbd787400d6f79753fb9759e3c54772d641ae7fd
4
+ data.tar.gz: 8eb5466b6ae94727f5142fb678a8e1a7c545e4c448006669d3e08ace9fcb6338
5
5
  SHA512:
6
- metadata.gz: cf5d23c33daedaaa38c3e56cd689a8bb99ef720f8efe8ddfbdf6c0a686bf8749e208503b00e3ea1990608fd83d2c86f1159446d07314c02f159dcad892086989
7
- data.tar.gz: 6b2052bc442d517c26186e412dacb3fb94f3b23c0aa21c24937686e1263ee9c3a07ecd21b139b49a5498a4787ea0ae8e12579e908acc86da530c2a1a5e5eca6a
6
+ metadata.gz: 9ace8095d996cafd7ecc92fa453263c0bc3c98f07af485c7bc743a65f57d1ad2139951a25af9a1eb004e266d1f37ba118daf747d7a710b945369b6bfeb36172d
7
+ data.tar.gz: 7a95c3ce305418b022778fd1c003c2dc5d6d0f42294bfd6351c96cbc20b67298015e4f1cf505d0a9196b56fa2232aac02e2a0e757a24988ac747591ad1762b7d
@@ -4,174 +4,205 @@ require 'rspec'
4
4
 
5
5
  # This file contains assertion methods which are called from assertion_steps.rb
6
6
 
7
- # Method to return page title
8
- def get_page_title
9
- $driver.title
10
- end
11
-
12
7
  # Method to verify title
13
8
  # param 1: String : expected title
14
9
  def assert_title(title)
15
- expect(get_page_title).to eq(title)
16
- end
17
-
18
- # Method to get element text
19
- # param : String
20
- def get_element_text(element)
21
- find_object(element).text
10
+ expect($driver.title).to eq(title)
22
11
  end
23
12
 
24
13
  # Method to check element text
25
14
  # param 1 : String : Element
26
15
  # param 2 : String : Expected element text
27
16
  def assert_text(element, expected_value)
28
- element_text = get_element_text(element)
17
+ found_element = find_object(element)
18
+ element_text = found_element.text
29
19
  expect(element_text).to eq(expected_value)
30
20
  end
31
21
 
32
- # Method to check partial element text
33
- # param 1 : String : Element
34
- # param 2 : String : Expected element partial text
35
- # param 3 : Boolean : test case [true or flase]
36
- def check_element_partial_text(element, expected_value, test_case)
37
- element_text = get_element_text(element)
38
-
39
- if test_case
40
- if not element_text.include? "#{expected_value}"
41
- raise TestCaseFailed, "Text Not Matched. Actual Value :#{expected_value}"
42
- end
43
- else
44
- if element_text.include? "#{expected_value}"
45
- raise TestCaseFailed, "Text Matched. Actual Value :#{expected_value}"
46
- end
47
- end
22
+ # method to check element presence
23
+ # param 1: String: Element
24
+ def assert_element_present(element)
25
+ found_element = find_object(element)
26
+ expect(found_element.length).to be > 0
48
27
  end
49
28
 
50
- # method to return element status - enabled?
51
- # param : String : Element
52
- def is_element_enabled(element)
53
- WAIT.until{ find_object(element) }.enabled?
29
+ # method to check element not presence
30
+ # param 1: String: Element
31
+ def assert_element_not_present(element)
32
+ found_element = find_object(element)
33
+ expect(found_element.length).to eq(0)
54
34
  end
55
35
 
56
- # method to check element status - enabled?
36
+ # method to assert checkbox check
57
37
  # param 1 : String : Element
58
- # param 2 : Boolean : test case [true or flase]
59
- def check_element_enable(element, test_case)
60
- result = is_element_enabled(element)
38
+ def assert_checked(element)
39
+ checkbox = find_object(element)
40
+ expect(checkbox.selected?).to be_truthy
41
+ end
61
42
 
62
- if test_case
63
- raise TestCaseFailed, 'Element Not Enabled' unless result
64
- else
65
- raise TestCaseFailed, 'Element Enabled' unless !result
66
- end
43
+ def assert_not_checked(element)
44
+ checkbox = find_object(element)
45
+ expect(checkbox.selected?).to be_falsey
67
46
  end
68
47
 
69
- # method to check attribute value
70
- # param 1 : String : Element
71
- # param 2 : String : atrribute name
72
- # param 3 : String : atrribute value
73
- # param 4 : Boolean : test case [true or flase]
74
- def check_element_attribute(element, attribute_name, attribute_value, test_case)
48
+ # method to check javascript pop-up alert text
49
+ def assert_alert(text)
50
+ alert_text = $driver.switch_to.alert.text
51
+ expect(alert_text).to eq(text)
52
+ end
75
53
 
76
- attr_val = get_element_attribute(element, attribute_name)
54
+ # method to check javascript pop-up alert text
55
+ def assert_confirmation(text)
56
+ alert_text = $driver.switch_to.alert.text
57
+ expect(alert_text).to eq(text)
58
+ end
77
59
 
78
- if test_case
79
- if attr_val != attribute_value
80
- raise TestCaseFailed, "Attribute Value Not Matched. Actual Value :#{attr_val}"
81
- end
82
- else
83
- if attr_val == attribute_value
84
- raise TestCaseFailed, "Attribute Value Matched. Actual Value :#{attr_val}"
85
- end
86
- end
60
+ def assert_editable(element)
61
+ found_element = find_object(element)
62
+ expect(found_element.enabled?).to be_truthy
87
63
  end
88
64
 
89
- # method to get element status - displayed?
90
- # param : String : Element
91
- def is_element_displayed(element)
92
- WAIT.until{ find_object(element) }.displayed?
65
+ def assert_not_editable
66
+ found_element = find_object(element)
67
+ expect(found_element.enabled?).to be_falsey
93
68
  end
94
69
 
95
- # method to check element presence
96
- # param 1 : String : Element
97
- # param 2 : Boolean : test case [true or flase]
98
- def assert_element_present(element)
70
+ def assert_not_selected_value(element, text)
99
71
  found_element = find_object(element)
100
- raise TestCaseFailed, 'Element Not Present' unless found_element.length > 0
72
+ value = found_element.attribute("value")
73
+ expect(value).not_to eq(text)
101
74
  end
102
75
 
103
- # method to assert checkbox check
104
- # param 1 : String : Element
105
- def assert_checked(element)
106
- checkbox = find_object(element)
76
+ def assert_not_text(element, text)
77
+ found_element = find_object(element)
78
+ expect(found_element.text).not_to eq(text)
79
+ end
107
80
 
108
- if !checkbox.selected?
109
- raise TestCaseFailed, "Checkbox is not checked"
110
- end
81
+ def assert_prompt(text)
82
+ alert_text = $driver.switch_to.alert.text
83
+ expect(alert_text).to eq(text)
111
84
  end
112
85
 
113
- def assert_not_checked(element)
114
- checkbox = find_object(element)
86
+ def assert_selected_label(element, text)
87
+ found_element = find_object(element)
88
+ locator = "option[@value='#{found_element.attribute('value')}']"
89
+ selected_text = found_element.find_element(:xpath, locator).text
90
+ expect(selected_text).to eq(text)
91
+ end
115
92
 
116
- if checkbox.selected?
117
- raise TestCaseFailed, "Checkbox is checked"
93
+ def assert_value(element, text)
94
+ found_element = find_object(element)
95
+ value = found_element.attribute("value")
96
+ expect(value).to eq(text)
97
+ end
98
+
99
+ def assert_selected_value
100
+ found_element = find_object(element)
101
+ value = found_element.attribute("value")
102
+ expect(value).to eq(text)
103
+ end
104
+
105
+ def assert(var_name, value)
106
+ if (value == "true" || value == "false")
107
+ _value = value
108
+ else elseif (value == '0' || !!number_or_nil(value))
109
+ _value = value
118
110
  end
111
+ result = _value
112
+ ? expect($vars[var_name]).to eq(_value)
113
+ : expect($vars[var_name]).to eq(value)
114
+ end
115
+
116
+ # Method to verify title
117
+ # param 1: String : expected title
118
+ def verify_title(title)
119
+ expect($driver.title).to eq(title)
119
120
  end
120
121
 
121
- # method to assert radio button selected/unselected
122
+ # Method to check element text
122
123
  # param 1 : String : Element
123
- # param 2 : Boolean : test case [true or flase]
124
- def is_radio_button_selected(element, should_be_selected = true)
125
- radio_button = WAIT.until{ find_object(element) }
126
-
127
- if !radio_button.selected? && should_be_selected
128
- raise TestCaseFailed, 'Radio Button not selected'
129
- elsif radio_button.selected? && !should_be_selected
130
- raise TestCaseFailed, 'Radio Button is selected'
131
- end
124
+ # param 2 : String : Expected element text
125
+ def verify_text(element, expected_value)
126
+ found_element = find_object(element)
127
+ element_text = found_element.text
128
+ expect(element_text).to eq(expected_value)
132
129
  end
133
130
 
134
- # method to assert option from radio button group is selected/unselected
135
- def is_option_from_radio_button_group_selected(element, by, option, should_be_selected = true)
136
- radio_button_group = WAIT.until{ find_object(element) }
131
+ # method to check element presence
132
+ # param 1: String: Element
133
+ def verify_element_present(element)
134
+ found_element = find_object(element)
135
+ expect(found_element.length).to be > 0
136
+ end
137
137
 
138
- getter = ->(rb, by) { by == 'value' ? rb.attribute('value') : rb.text }
138
+ # method to check element not presence
139
+ # param 1: String: Element
140
+ def verify_element_not_present(element)
141
+ found_element = find_object(element)
142
+ expect(found_element.length).to eq(0)
143
+ end
139
144
 
140
- ele = radio_button_group.find { |rb| getter.call(rb, by) == option }
145
+ # method to assert checkbox check
146
+ # param 1 : String : Element
147
+ def verify_checked(element)
148
+ checkbox = find_object(element)
149
+ expect(checkbox.selected?).to be_truthy
150
+ end
141
151
 
142
- if !ele.selected? && should_be_selected
143
- raise TestCaseFailed, 'Radio button is not selected'
144
- elsif ele.selected? && !should_be_selected
145
- raise TestCaseFailed, 'Radio button is selected'
146
- end
152
+ def verify_not_checked(element)
153
+ checkbox = find_object(element)
154
+ expect(checkbox.selected?).to be_falsey
147
155
  end
148
156
 
149
- # method to get javascript pop-up alert text
150
- def get_alert_text
151
- $driver.switch_to.alert.text
157
+ def verify_editable(element)
158
+ found_element = find_object(element)
159
+ expect(found_element.enabled?).to be_truthy
152
160
  end
153
161
 
154
- # method to check javascript pop-up alert text
155
- def assert_alert(text)
156
- alert_text = $driver.switch_to.alert.text
157
- expect(alert_text).to eq(text)
162
+ def verify_not_editable
163
+ found_element = find_object(element)
164
+ expect(found_element.enabled?).to be_falsey
158
165
  end
159
166
 
160
- def is_option_from_dropdown_selected(element, by, option, should_be_selected=true)
161
- dropdown = WAIT.until { find_object(element) }
162
- select_list = Selenium::WebDriver::Support::Select.new(dropdown)
167
+ def verify_not_selected_value(element, text)
168
+ found_element = find_object(element)
169
+ value = found_element.attribute("value")
170
+ expect(value).not_to eq(text)
171
+ end
163
172
 
164
- if by == 'text'
165
- actual_value = select_list.first_selected_option.text
166
- else
167
- actual_value = select_list.first_selected_option.attribute('value')
168
- end
173
+ def verify_not_text(element, text)
174
+ found_element = find_object(element)
175
+ expect(found_element.text).not_to eq(text)
176
+ end
177
+
178
+ def verify_selected_label(element, text)
179
+ found_element = find_object(element)
180
+ locator = "option[@value='#{found_element.attribute('value')}']"
181
+ selected_text = found_element.find_element(:xpath, locator).text
182
+ expect(selected_text).to eq(text)
183
+ end
184
+
185
+ def verify_value(element, text)
186
+ found_element = find_object(element)
187
+ value = found_element.attribute("value")
188
+ expect(value).to eq(text)
189
+ end
190
+
191
+ def verify_selected_value
192
+ found_element = find_object(element)
193
+ value = found_element.attribute("value")
194
+ expect(value).to eq(text)
195
+ end
169
196
 
170
- if !actual_value == option && should_be_selected
171
- raise TestCaseFailed, 'Option Not Selected From Dropwdown'
172
- elsif actual_value == option && !should_be_selected
173
- raise TestCaseFailed, 'Option Selected From Dropwdown'
197
+ def verify(var_name, value)
198
+ if (value == "true" || value == "false")
199
+ _value = value
200
+ else elseif (value == '0' || !!number_or_nil(value))
201
+ _value = value
174
202
  end
203
+ result = _value
204
+ ? expect($vars[var_name]).to eq(_value)
205
+ : expect($vars[var_name]).to eq(value)
175
206
  end
176
207
 
177
208
  # Method to find difference between images
@@ -280,3 +311,8 @@ def compare_png_images(expected_img_url, actual_img_url)
280
311
  end
281
312
  true
282
313
  end
314
+
315
+ def number_or_nil(string)
316
+ num = string.to_i
317
+ num if num.to_s == string
318
+ end
@@ -7,9 +7,9 @@ def print_congifugartion
7
7
  puts "Time : #{Time.now.strftime("%I:%M:%S:%p")}"
8
8
 
9
9
  if $platform == 'android' or $platform == 'ios'
10
- print_mobile_configuration
10
+ print_mobile_configuration
11
11
  else
12
- print_desktop_configuration
12
+ print_desktop_configuration
13
13
  end
14
14
  end
15
15
 
@@ -27,9 +27,9 @@ def print_mobile_configuration
27
27
  puts "Device : #{$device_name}"
28
28
 
29
29
  if $app_path.nil?
30
- puts 'Browser : ' + $driver.capabilities.browser_name.to_s.upcase + " " + $driver.capabilities.version.to_s
30
+ puts 'Browser : ' + $driver.capabilities.browser_name.to_s.upcase + " " + $driver.capabilities.version.to_s
31
31
  else
32
- puts "App Tested : #{$app_path}"
32
+ puts "App Tested : #{$app_path}"
33
33
  end
34
34
  puts ''
35
35
  end
@@ -37,3 +37,6 @@ end
37
37
  def echo(message)
38
38
  puts(message)
39
39
  end
40
+
41
+ def debugger
42
+ end
@@ -53,7 +53,7 @@ end
53
53
 
54
54
  # method to toggle checkbox checked
55
55
  def toggle_checkbox(element)
56
- WAIT.until { find_object(element) }.click
56
+ find_object(element).click
57
57
  end
58
58
 
59
59
  # method to select radio button
@@ -70,3 +70,43 @@ def select_option_from_radio_button_group(element, by, option)
70
70
  ele = radio_button_group.find { |rb| getter.call(rb, by) == option }
71
71
  ele.click unless ele.selected?
72
72
  end
73
+
74
+ def edit_content(element, text)
75
+ found_element = find_object(element)
76
+ $driver.execute_script("if (arguments[0].contentEditable === 'true') {arguments[0].innerText = '#{text}'}", found_element)
77
+ end
78
+
79
+ def add_selection(label)
80
+ found_element = find_object(element)
81
+ found_element.find_element(:xpath, "//option[. = '#{label}']").click
82
+ end
83
+
84
+ def remove_selection
85
+ found_element = find_object(element)
86
+ found_element.find_element(:xpath, "//option[. = '#{label}']").click
87
+ end
88
+
89
+ def select
90
+ found_element = find_object(element)
91
+ found_element.find_element(:xpath, "//option[. = '#{label}']").click
92
+ end
93
+
94
+ def drag_and_drop_to_object(element, drop_element)
95
+ dragged = find_object(element)
96
+ object_value_regex = /^(class=|css=|id=|name=|xpath=|className=|link=|linkText=|partialLinkText=)/
97
+ object_type_regex = /^(class|css|id|name|xpath|className|link|linkText|partialLinkText)/
98
+ if object_value_regex.match?(drop_element)
99
+ object_value = drop_element.gsub(object_value_regex, "")
100
+ object_type = drop_element.split(object_type_regex)[1].underscore
101
+ dropped = $driver.find_element(object_type.to_sym, object_value)
102
+ $driver.action.drag_and_drop(dragged, dropped).perform
103
+ else
104
+ raise TestCaseFailed, "Option locator not supported"
105
+ end
106
+ end
107
+
108
+ def select_window(element)
109
+ end
110
+
111
+ def select_frame(element)
112
+ end
@@ -4,12 +4,79 @@ def pause(time)
4
4
  sleep time.to_i
5
5
  end
6
6
 
7
- def wait_for_element_to_display(element, duration)
8
- wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i) # seconds
7
+ def wait_for_element_editable(element, duration)
8
+ wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i / 1000)
9
+ wait.until { find_object(element).enabled? }
10
+ end
11
+
12
+ def wait_for_element_not_editable(element, duration)
13
+ wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i / 1000)
14
+ wait.until { !find_object(element).enabled? }
15
+ end
16
+
17
+ def wait_for_element_not_present(element, duration)
18
+ wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i / 1000)
19
+ wait.until do
20
+ begin
21
+ !find_object(element)
22
+ rescue Selenium::WebDriver::Error::NoSuchElementError
23
+ true
24
+ end
25
+ end
26
+ end
27
+
28
+ def wait_for_element_not_visible(element, duration)
29
+ wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i / 1000)
30
+ wait.until { !find_object(element).displayed? }
31
+ end
32
+
33
+ def wait_for_text(element, text)
34
+ wait = Selenium::WebDriver::Wait.new(:timeout => 30)
35
+ wait.until { find_object(element).text == text }
36
+ end
37
+
38
+ def wait_for_element_visible(element, duration)
39
+ wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i / 1000)
9
40
  wait.until { find_object(element).displayed? }
10
41
  end
11
42
 
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? }
43
+ def wait_for_element_present(element, duration)
44
+ wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i / 1000)
45
+ wait.until { find_object(element) }
46
+ end
47
+
48
+ def answer_on_next_prompt(answer)
49
+ alert = $driver.switch_to.alert
50
+ alert.send_keys(answer)
51
+ alert.accept()
52
+ end
53
+
54
+ def choose_cancel_on_next_confirmation
55
+ $driver.switch_to.alert.dismiss
56
+ end
57
+
58
+ def choose_cancel_on_next_prompt
59
+ $driver.switch_to.alert.dismiss
60
+ end
61
+
62
+ def choose_ok_on_next_confirmation
63
+ $driver.switch_to.alert.accept
64
+ end
65
+
66
+ def webdriver_answer_on_visible_prompt
67
+ alert = $driver.switch_to.alert
68
+ alert.send_keys(answer)
69
+ alert.accept()
70
+ end
71
+
72
+ def webdriver_choose_cancel_on_visible_confirmation
73
+ $driver.switch_to.alert.dismiss
74
+ end
75
+
76
+ def webdriver_choose_ok_on_visible_confirmation
77
+ $driver.switch_to.alert.accept
78
+ end
79
+
80
+ def webdriver_choose_cancel_on_visible_prompt
81
+ $driver.switch_to.alert.dismiss
15
82
  end
@@ -0,0 +1,36 @@
1
+ require 'net/https'
2
+ require_relative 'required_files'
3
+ require 'rspec'
4
+
5
+ def store(var_name, value)
6
+ $vars[var_name] = value
7
+ end
8
+
9
+ def store_json(var_name, value)
10
+ $vars[var_name] = JSON.parse(value)
11
+ end
12
+
13
+ def store_text(element, var_name)
14
+ found_element = find_object(element)
15
+ element_text = found_element.text
16
+ $vars[var_name] = element_text
17
+ end
18
+
19
+ def store_title(var_name)
20
+ $vars[var_name] = $driver.title
21
+ end
22
+
23
+ def store_xpath_count(element, var_name)
24
+ found_element = find_object(element)
25
+ $vars[var_name] = found_element.length
26
+ end
27
+
28
+ def store_window_handle(var_name)
29
+ $vars[var_name] = $driver.window_handle
30
+ end
31
+
32
+ def store_attribute(element, attribute, var_name)
33
+ found_element = find_object(element)
34
+ value = found_element.attribute(attribute)
35
+ $vars[var_name] = value
36
+ end
@@ -1,5 +1,5 @@
1
1
  module ITMS
2
2
  module Automation
3
- VERSION = '2.7.1'
3
+ VERSION = '2.7.6'
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.7.1
4
+ version: 2.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - INFOdation
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-07 00:00:00.000000000 Z
11
+ date: 2021-04-12 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: 5.2.0
19
+ version: 3.1.2
20
20
  - - "~>"
21
21
  - !ruby/object:Gem::Version
22
- version: 5.2.0
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: 5.2.0
29
+ version: 3.1.2
30
30
  - - "~>"
31
31
  - !ruby/object:Gem::Version
32
- version: 5.2.0
32
+ version: 3.1.2
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: webdrivers
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -179,6 +179,7 @@ files:
179
179
  - lib/itms_automation/methods/progress_methods.rb
180
180
  - lib/itms_automation/methods/required_files.rb
181
181
  - lib/itms_automation/methods/screenshot_methods.rb
182
+ - lib/itms_automation/methods/store_methods.rb
182
183
  - lib/itms_automation/navigation_steps.rb
183
184
  - lib/itms_automation/progress_steps.rb
184
185
  - lib/itms_automation/screenshot_steps.rb