itms_automation 2.6.9 → 2.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features-skeleton/support/env.rb +23 -22
- data/lib/itms_automation/methods/assertion_methods.rb +158 -173
- data/lib/itms_automation/methods/click_elements_methods.rb +13 -6
- data/lib/itms_automation/methods/condition_methods.rb +13 -0
- data/lib/itms_automation/methods/configuration_methods.rb +14 -7
- data/lib/itms_automation/methods/input_methods.rb +58 -15
- data/lib/itms_automation/methods/javascript_handling_methods.rb +1 -1
- data/lib/itms_automation/methods/misc_methods.rb +1 -1
- data/lib/itms_automation/methods/navigate_methods.rb +52 -45
- data/lib/itms_automation/methods/progress_methods.rb +73 -6
- data/lib/itms_automation/methods/store_methods.rb +36 -0
- data/lib/itms_automation/version.rb +1 -1
- metadata +25 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a0b67a5af9ae7b5abab5f2993983dd70c104608d1895aeed6ad63a034f1f8e0
|
4
|
+
data.tar.gz: 10cdb6858de34421b696c131553f2247663d785cdf2f648bccdfd20a28763aea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2e9ddac84ad149c3cb5d71eaae39cf0710d150d35f0479095696134a5ba3cc2e1bd4f83c40cc2f3c5991c2c69f04e41429ee60fe582aa7000b90c803ab9295c
|
7
|
+
data.tar.gz: 9a628c5bc6d8d62ee7ec9f68756aed60017d7be67585d0ca604c2fd28fbf024b193dd39d240c1f03abb4a4231b9d6f5d013ffd64b9fd081136ee65d9bd3e4f7c
|
@@ -7,32 +7,33 @@ require "webdrivers"
|
|
7
7
|
$browser_type = ENV["BROWSER"] || "firefox"
|
8
8
|
|
9
9
|
begin
|
10
|
+
$vars = {}
|
10
11
|
$driver = case $browser_type
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
12
|
+
when "chrome"
|
13
|
+
Selenium::WebDriver.for(:chrome)
|
14
|
+
when "safari"
|
15
|
+
Selenium::WebDriver.for(:safari)
|
16
|
+
when "internet_explorer"
|
17
|
+
Selenium::WebDriver.for(:internet_explorer)
|
18
|
+
when "chrome_headless"
|
19
|
+
Selenium::WebDriver.for(:chrome, :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: { args: %w(headless) }))
|
20
|
+
when "remote"
|
21
|
+
if ENV['SERVER_URL'].nil? || ENV['REMOTE_BROWSER'].nil?
|
22
|
+
puts "\nMissing SERVER_URL : SERVER_URL=http//SERVER_URL:4444/wd/hub"
|
23
|
+
puts "\nMissing REMOTE_BROWSER: REMOTE_BROWSER=browser_name"
|
24
|
+
Process.exit(0)
|
25
|
+
else
|
26
|
+
caps = Selenium::WebDriver::Remote::Capabilities.new
|
27
|
+
caps["browserName"] = ENV["REMOTE_BROWSER"]
|
28
|
+
caps["enableVNC"] = false
|
29
|
+
caps["enableVideo"] = false
|
30
|
+
caps["resolution"] = ENV["resolution"] unless ENV["resolution"]
|
31
|
+
Selenium::WebDriver.for(:remote, :url => ENV["SERVER_URL"], :desired_capabilities => caps)
|
32
|
+
end
|
32
33
|
else
|
33
34
|
Selenium::WebDriver.for(:firefox)
|
34
35
|
end
|
35
36
|
rescue Exception => e
|
36
37
|
puts e.message
|
37
38
|
Process.exit(0)
|
38
|
-
end
|
39
|
+
end
|
@@ -1,228 +1,208 @@
|
|
1
1
|
require 'net/https'
|
2
2
|
require_relative 'required_files'
|
3
|
+
require 'rspec'
|
3
4
|
|
4
5
|
# This file contains assertion methods which are called from assertion_steps.rb
|
5
6
|
|
6
|
-
# Method to
|
7
|
-
|
8
|
-
|
7
|
+
# Method to verify title
|
8
|
+
# param 1: String : expected title
|
9
|
+
def assert_title(title)
|
10
|
+
expect($driver.title).to eq(title)
|
9
11
|
end
|
10
12
|
|
11
|
-
# Method to
|
12
|
-
# param 1 : String :
|
13
|
-
# param 2 :
|
14
|
-
def
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
raise TestCaseFailed, "Page Title Not Matched, Actual Page Title : #{page_title}"
|
19
|
-
end
|
20
|
-
else
|
21
|
-
if page_title == "#{title}"
|
22
|
-
raise TestCaseFailed, "Page Title Matched, Actual Page Title:#{page_title}"
|
23
|
-
end
|
24
|
-
end
|
13
|
+
# Method to check element text
|
14
|
+
# param 1 : String : Element
|
15
|
+
# param 2 : String : Expected element text
|
16
|
+
def assert_text(element, expected_value)
|
17
|
+
found_element = find_object(element)
|
18
|
+
element_text = found_element.text
|
19
|
+
expect(element_text).to eq(expected_value)
|
25
20
|
end
|
26
21
|
|
27
|
-
#
|
28
|
-
# param 1
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
if test_case
|
33
|
-
if not page_title.include? "#{partial_text_title}"
|
34
|
-
raise TestCaseFailed, 'Partial Page Title Not Present'
|
35
|
-
end
|
36
|
-
else
|
37
|
-
if page_title.include? "#{partial_text_title}"
|
38
|
-
raise TestCaseFailed, 'Page Title Matched'
|
39
|
-
end
|
40
|
-
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
|
41
27
|
end
|
42
28
|
|
43
|
-
#
|
44
|
-
# param : String
|
45
|
-
def
|
46
|
-
|
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)
|
47
34
|
end
|
48
35
|
|
49
|
-
#
|
36
|
+
# method to assert checkbox check
|
50
37
|
# param 1 : String : Element
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
38
|
+
def assert_checked(element)
|
39
|
+
checkbox = find_object(element)
|
40
|
+
expect(checkbox.selected?).to be_truthy
|
41
|
+
end
|
55
42
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
60
|
-
else
|
61
|
-
if element_text == expected_value
|
62
|
-
raise TestCaseFailed, "Text Matched. Actual Value :#{expected_value}"
|
63
|
-
end
|
64
|
-
end
|
43
|
+
def assert_not_checked(element)
|
44
|
+
checkbox = find_object(element)
|
45
|
+
expect(checkbox.selected?).to be_falsey
|
65
46
|
end
|
66
47
|
|
67
|
-
#
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
def check_element_partial_text(element, expected_value, test_case)
|
72
|
-
element_text = get_element_text(element)
|
73
|
-
|
74
|
-
if test_case
|
75
|
-
if not element_text.include? "#{expected_value}"
|
76
|
-
raise TestCaseFailed, "Text Not Matched. Actual Value :#{expected_value}"
|
77
|
-
end
|
78
|
-
else
|
79
|
-
if element_text.include? "#{expected_value}"
|
80
|
-
raise TestCaseFailed, "Text Matched. Actual Value :#{expected_value}"
|
81
|
-
end
|
82
|
-
end
|
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)
|
83
52
|
end
|
84
53
|
|
85
|
-
# method to
|
86
|
-
|
87
|
-
|
88
|
-
|
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)
|
89
58
|
end
|
90
59
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
result = is_element_enabled(element)
|
60
|
+
def assert_editable(element)
|
61
|
+
found_element = find_object(element)
|
62
|
+
expect(found_element.enabled?).to be_truthy
|
63
|
+
end
|
96
64
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
raise TestCaseFailed, 'Element Enabled' unless !result
|
101
|
-
end
|
65
|
+
def assert_not_editable
|
66
|
+
found_element = find_object(element)
|
67
|
+
expect(found_element.enabled?).to be_falsey
|
102
68
|
end
|
103
69
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
WAIT.until{ find_object(element) }.attribute("#{attribute_name}")
|
70
|
+
def assert_not_selected_value(element, text)
|
71
|
+
found_element = find_object(element)
|
72
|
+
value = found_element.attribute("value")
|
73
|
+
expect(value).not_to eq(text)
|
109
74
|
end
|
110
75
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
def
|
76
|
+
def assert_not_text(element, text)
|
77
|
+
found_element = find_object(element)
|
78
|
+
expect(found_element.text).not_to eq(text)
|
79
|
+
end
|
80
|
+
|
81
|
+
def assert_prompt(text)
|
82
|
+
alert_text = $driver.switch_to.alert.text
|
83
|
+
expect(alert_text).to eq(text)
|
84
|
+
end
|
117
85
|
|
118
|
-
|
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
|
119
92
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
else
|
125
|
-
if attr_val == attribute_value
|
126
|
-
raise TestCaseFailed, "Attribute Value Matched. Actual Value :#{attr_val}"
|
127
|
-
end
|
128
|
-
end
|
93
|
+
def assert_value(element, text)
|
94
|
+
found_element = find_object(element)
|
95
|
+
value = found_element.attribute("value")
|
96
|
+
expect(value).to eq(text)
|
129
97
|
end
|
130
98
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
99
|
+
def assert_selected_value
|
100
|
+
found_element = find_object(element)
|
101
|
+
value = found_element.attribute("value")
|
102
|
+
expect(value).to eq(text)
|
135
103
|
end
|
136
104
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
if !is_element_displayed(element)
|
143
|
-
raise TestCaseFailed, 'Element Not Present'
|
144
|
-
end
|
145
|
-
else
|
146
|
-
begin
|
147
|
-
if is_element_displayed(element)
|
148
|
-
raise 'Present' # since it is negative test and we found element
|
149
|
-
end
|
150
|
-
rescue Exception => e
|
151
|
-
if e.message == 'Present' # only raise if it present
|
152
|
-
raise TestCaseFailed, 'Element Present'
|
153
|
-
end
|
154
|
-
end
|
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
|
155
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)
|
156
120
|
end
|
157
121
|
|
158
|
-
#
|
122
|
+
# Method to check element text
|
159
123
|
# param 1 : String : Element
|
160
|
-
# param 2 :
|
161
|
-
def
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
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)
|
129
|
+
end
|
130
|
+
|
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
|
169
136
|
end
|
170
137
|
|
171
|
-
# method to
|
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
|
144
|
+
|
145
|
+
# method to assert checkbox check
|
172
146
|
# param 1 : String : Element
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
if !radio_button.selected? && should_be_selected
|
178
|
-
raise TestCaseFailed, 'Radio Button not selected'
|
179
|
-
elsif radio_button.selected? && !should_be_selected
|
180
|
-
raise TestCaseFailed, 'Radio Button is selected'
|
181
|
-
end
|
147
|
+
def verify_checked(element)
|
148
|
+
checkbox = find_object(element)
|
149
|
+
expect(checkbox.selected?).to be_truthy
|
182
150
|
end
|
183
151
|
|
184
|
-
|
185
|
-
|
186
|
-
|
152
|
+
def verify_not_checked(element)
|
153
|
+
checkbox = find_object(element)
|
154
|
+
expect(checkbox.selected?).to be_falsey
|
155
|
+
end
|
187
156
|
|
188
|
-
|
157
|
+
def verify_editable(element)
|
158
|
+
found_element = find_object(element)
|
159
|
+
expect(found_element.enabled?).to be_truthy
|
160
|
+
end
|
189
161
|
|
190
|
-
|
162
|
+
def verify_not_editable
|
163
|
+
found_element = find_object(element)
|
164
|
+
expect(found_element.enabled?).to be_falsey
|
165
|
+
end
|
191
166
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
end
|
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)
|
197
171
|
end
|
198
172
|
|
199
|
-
|
200
|
-
|
201
|
-
|
173
|
+
def verify_not_text(element, text)
|
174
|
+
found_element = find_object(element)
|
175
|
+
expect(found_element.text).not_to eq(text)
|
202
176
|
end
|
203
177
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
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)
|
209
183
|
end
|
210
184
|
|
211
|
-
def
|
212
|
-
|
213
|
-
|
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
|
214
190
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
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
|
220
196
|
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
197
|
+
def verify(var_name, value)
|
198
|
+
if (value == "true" || value == "false") {
|
199
|
+
_value = value
|
200
|
+
} elseif (value == '0' || !!number_or_nil(value)) {
|
201
|
+
_value = value
|
202
|
+
}
|
203
|
+
result = _value
|
204
|
+
? expect($vars[var_name]).to eq(_value)
|
205
|
+
: expect($vars[var_name]).to eq(value)
|
226
206
|
end
|
227
207
|
|
228
208
|
# Method to find difference between images
|
@@ -331,3 +311,8 @@ def compare_png_images(expected_img_url, actual_img_url)
|
|
331
311
|
end
|
332
312
|
true
|
333
313
|
end
|
314
|
+
|
315
|
+
def number_or_nil(string)
|
316
|
+
num = string.to_i
|
317
|
+
num if num.to_s == string
|
318
|
+
end
|
@@ -1,20 +1,27 @@
|
|
1
1
|
require_relative 'required_files'
|
2
2
|
|
3
3
|
def click(element)
|
4
|
-
|
4
|
+
found_element = find_object(element)
|
5
|
+
found_element.click
|
5
6
|
end
|
6
7
|
|
7
|
-
def
|
8
|
-
|
8
|
+
def click_at(element)
|
9
|
+
found_element = find_object(element)
|
10
|
+
found_element.click
|
9
11
|
end
|
10
12
|
|
11
13
|
def double_click(element)
|
12
|
-
found_element =
|
14
|
+
found_element = find_object(element)
|
13
15
|
$driver.action.double_click(found_element).perform
|
14
16
|
end
|
15
17
|
|
16
|
-
def
|
17
|
-
found_element =
|
18
|
+
def double_click_at(element, location)
|
19
|
+
found_element = find_object(element)
|
20
|
+
$driver.action.double_click(found_element).perform
|
21
|
+
end
|
22
|
+
|
23
|
+
def long_press(element, duration)
|
24
|
+
found_element = find_object(element)
|
18
25
|
parameters = { "element" => "#{found_element}", "duration" => "#{duration}" }
|
19
26
|
args = parameters.select { |k, v| [:element, :duration].include? k }
|
20
27
|
args = args_with_ele_ref(args)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative 'required_files'
|
2
|
+
|
3
|
+
def if(condition_script)
|
4
|
+
return $driver.execute_script(condition_script)
|
5
|
+
end
|
6
|
+
|
7
|
+
def else_if(condition_script)
|
8
|
+
return $driver.execute_script(condition_script)
|
9
|
+
end
|
10
|
+
|
11
|
+
def while(condition_script)
|
12
|
+
return $driver.execute_script(condition_script)
|
13
|
+
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
|
-
|
10
|
+
print_mobile_configuration
|
11
11
|
else
|
12
|
-
|
12
|
+
print_desktop_configuration
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -22,14 +22,21 @@ end
|
|
22
22
|
|
23
23
|
# method to print mobile configuration
|
24
24
|
def print_mobile_configuration
|
25
|
-
puts "Platform : #{$platform.upcase}"
|
26
|
-
puts "OS version : #{$os_version}"
|
27
|
-
puts "Device : #{$device_name}"
|
25
|
+
puts "Platform : #{$platform.upcase}"
|
26
|
+
puts "OS version : #{$os_version}"
|
27
|
+
puts "Device : #{$device_name}"
|
28
28
|
|
29
29
|
if $app_path.nil?
|
30
|
-
|
30
|
+
puts 'Browser : ' + $driver.capabilities.browser_name.to_s.upcase + " " + $driver.capabilities.version.to_s
|
31
31
|
else
|
32
|
-
|
32
|
+
puts "App Tested : #{$app_path}"
|
33
33
|
end
|
34
34
|
puts ''
|
35
35
|
end
|
36
|
+
|
37
|
+
def echo(message)
|
38
|
+
puts(message)
|
39
|
+
end
|
40
|
+
|
41
|
+
def debugger
|
42
|
+
end
|
@@ -1,15 +1,21 @@
|
|
1
1
|
require_relative 'required_files'
|
2
2
|
|
3
3
|
# method to enter text into textfield
|
4
|
-
def
|
4
|
+
def type(element, text)
|
5
5
|
foundElement = find_object(element)
|
6
|
-
|
6
|
+
foundElement.send_keys(text)
|
7
7
|
end
|
8
8
|
|
9
|
-
# method to
|
10
|
-
def
|
9
|
+
# method to send keys
|
10
|
+
def send_keys(element, key)
|
11
|
+
keys_support = ["KEY_LEFT", "KEY_UP", "KEY_RIGHT", "KEY_DOWN", "KEY_PAGE_UP", "KEY_PAGE_DOWN", "KEY_BACKSPACE", "KEY_DELETE", "KEY_ENTER", "KEY_TAB"]
|
11
12
|
foundElement = find_object(element)
|
12
|
-
|
13
|
+
if key
|
14
|
+
get_key = key.strip[/^\$\{(.*?)\}$/, 1]
|
15
|
+
raise TestCaseFailed, "${get_key} key is not supported. Supported keys: KEY_LEFT, KEY_UP, KEY_RIGHT, KEY_DOWN, KEY_PAGE_UP, KEY_PAGE_DOWN, KEY_BACKSPACE, KEY_DELETE, KEY_ENTER, KEY_TAB" unless keys_support.include?(get_key)
|
16
|
+
key_convert = get_key[/^KEY_(.*?)$/, 1].downcase.to_sym
|
17
|
+
foundElement.send_keys(key_convert)
|
18
|
+
end
|
13
19
|
end
|
14
20
|
|
15
21
|
# method to select option from dropdwon list
|
@@ -34,23 +40,20 @@ def unselect_all_option_from_multiselect_dropdown(element)
|
|
34
40
|
end
|
35
41
|
|
36
42
|
# method to check checkbox
|
37
|
-
def
|
38
|
-
checkbox =
|
43
|
+
def check(element)
|
44
|
+
checkbox = find_object(element)
|
39
45
|
checkbox.click unless checkbox.selected?
|
40
46
|
end
|
41
47
|
|
42
48
|
# method to uncheck checkbox
|
43
|
-
def
|
44
|
-
checkbox =
|
45
|
-
|
46
|
-
if checkbox.selected?
|
47
|
-
checkbox.click
|
48
|
-
end
|
49
|
+
def uncheck(element)
|
50
|
+
checkbox = find_object(element)
|
51
|
+
checkbox.click if checkbox.selected?
|
49
52
|
end
|
50
53
|
|
51
|
-
# method to
|
54
|
+
# method to toggle checkbox checked
|
52
55
|
def toggle_checkbox(element)
|
53
|
-
|
56
|
+
find_object(element).click
|
54
57
|
end
|
55
58
|
|
56
59
|
# method to select radio button
|
@@ -67,3 +70,43 @@ def select_option_from_radio_button_group(element, by, option)
|
|
67
70
|
ele = radio_button_group.find { |rb| getter.call(rb, by) == option }
|
68
71
|
ele.click unless ele.selected?
|
69
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
|
@@ -1,21 +1,25 @@
|
|
1
1
|
require_relative 'required_files'
|
2
2
|
|
3
3
|
# method to open link
|
4
|
-
def
|
4
|
+
def open(link)
|
5
5
|
$driver.get link
|
6
6
|
end
|
7
7
|
|
8
8
|
# method to navigate back & forward
|
9
9
|
def navigate(direction)
|
10
10
|
if direction == 'back'
|
11
|
-
|
11
|
+
$driver.navigate.back
|
12
12
|
else
|
13
13
|
$driver.navigate.forward
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
def close
|
18
|
+
$drive.close
|
19
|
+
end
|
20
|
+
|
17
21
|
# method to quite webdriver instance
|
18
|
-
def
|
22
|
+
def quit
|
19
23
|
$driver.quit
|
20
24
|
end
|
21
25
|
|
@@ -39,7 +43,7 @@ end
|
|
39
43
|
# Method to zoom in/out web page until web element dislays
|
40
44
|
def zoom_in_out_till_element_display(element, in_out)
|
41
45
|
while true
|
42
|
-
if
|
46
|
+
if find_object(element).displayed?
|
43
47
|
break
|
44
48
|
else
|
45
49
|
$driver.action.key_down(:"#{get_key}").send_keys(:"#{in_out}").key_up(:"#{get_key}").perform
|
@@ -48,8 +52,10 @@ def zoom_in_out_till_element_display(element, in_out)
|
|
48
52
|
end
|
49
53
|
|
50
54
|
# Method to resize browser
|
51
|
-
def
|
52
|
-
|
55
|
+
def set_window_size(resolution)
|
56
|
+
raise TestCaseFailed, 'Wrong format of resolution. (e.g., 1280x800)' unless resolution.match(/^\d+x\d+$/)
|
57
|
+
width, height = resolution.split("x")
|
58
|
+
$driver.manage.resize_to(width, heigth)
|
53
59
|
end
|
54
60
|
|
55
61
|
# Method to maximize browser
|
@@ -63,14 +69,50 @@ def refresh_page
|
|
63
69
|
end
|
64
70
|
|
65
71
|
# Method to hover on element
|
66
|
-
def
|
67
|
-
element =
|
68
|
-
$driver.action.
|
72
|
+
def mouse_over(element)
|
73
|
+
element = find_object(element)
|
74
|
+
$driver.action.move_to_element(element).perform
|
75
|
+
end
|
76
|
+
|
77
|
+
# mouse_down
|
78
|
+
def mouse_down(element)
|
79
|
+
element = find_object(element)
|
80
|
+
$driver.action.move_to_element(element).click_and_hold.perform
|
81
|
+
end
|
82
|
+
|
83
|
+
# mouse_down_at
|
84
|
+
def mouse_down_at(element, location)
|
85
|
+
element = find_object(element)
|
86
|
+
$driver.action.move_to_element(element).click_and_hold.perform
|
87
|
+
end
|
88
|
+
|
89
|
+
# mouse_out
|
90
|
+
def mouse_out
|
91
|
+
element = $driver.find_element(By.CSS_SELECTOR, 'body')
|
92
|
+
$driver.action.move_to_element(element, 0, 0).perform
|
93
|
+
end
|
94
|
+
|
95
|
+
#mouse_up
|
96
|
+
def mouse_up(element)
|
97
|
+
element = find_object(element)
|
98
|
+
$driver.action.move_to_element(element).release.perform
|
99
|
+
end
|
100
|
+
|
101
|
+
#mouse_up_at
|
102
|
+
def mouse_up_at
|
103
|
+
element = find_object(element)
|
104
|
+
$driver.action.move_to_element(element).release.perform
|
105
|
+
end
|
106
|
+
|
107
|
+
#mouse_move_at
|
108
|
+
def mouse_move_at
|
109
|
+
element = find_object(element)
|
110
|
+
$driver.action.move_to_element(element).perform
|
69
111
|
end
|
70
112
|
|
71
113
|
# Method to scroll page to perticular element
|
72
114
|
def scroll_to_element(element)
|
73
|
-
ele_scroll =
|
115
|
+
ele_scroll = find_object(element)
|
74
116
|
ele_scroll.location_once_scrolled_into_view
|
75
117
|
end
|
76
118
|
|
@@ -84,38 +126,3 @@ def scroll_page(to)
|
|
84
126
|
raise "Exception : Invalid Direction (only scroll \"top\" or \"end\")"
|
85
127
|
end
|
86
128
|
end
|
87
|
-
|
88
|
-
$old_win = nil
|
89
|
-
|
90
|
-
# Method to switch to new window
|
91
|
-
def switch_to_new_window
|
92
|
-
$old_win = $driver.window_handle
|
93
|
-
$driver.switch_to.window($driver.window_handles[1])
|
94
|
-
end
|
95
|
-
|
96
|
-
# Method to switch to old window
|
97
|
-
def switch_to_old_window
|
98
|
-
$driver.switch_to.window($old_win)
|
99
|
-
end
|
100
|
-
|
101
|
-
# Method to close new window
|
102
|
-
def close_new_window
|
103
|
-
$driver.close
|
104
|
-
end
|
105
|
-
|
106
|
-
=begin
|
107
|
-
def switch_to_new_window
|
108
|
-
win_handles = $driver.window_handles
|
109
|
-
|
110
|
-
puts $driver.title
|
111
|
-
puts win_handles.length
|
112
|
-
|
113
|
-
$driver.switch_to.window($driver.window_handles[1])
|
114
|
-
puts $driver.window_handles[1]
|
115
|
-
puts $driver.title
|
116
|
-
|
117
|
-
$driver.switch_to.window($driver.window_handles[2])
|
118
|
-
puts $driver.window_handles[2]
|
119
|
-
puts $driver.title
|
120
|
-
end
|
121
|
-
=end
|
@@ -1,15 +1,82 @@
|
|
1
1
|
require_relative 'required_files'
|
2
2
|
|
3
|
-
def
|
3
|
+
def pause(time)
|
4
4
|
sleep time.to_i
|
5
5
|
end
|
6
6
|
|
7
|
-
def
|
8
|
-
wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i
|
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
|
13
|
-
wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i
|
14
|
-
wait.until { find_object(element)
|
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
|
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.
|
4
|
+
version: 2.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- INFOdation
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -110,6 +110,26 @@ dependencies:
|
|
110
110
|
- - "~>"
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '1.8'
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: rspec
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '3.5'
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '3.5'
|
123
|
+
type: :runtime
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '3.5'
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '3.5'
|
113
133
|
description: Behavior driven development (BDD) approach to write automation test script
|
114
134
|
to test Web and Android applications.
|
115
135
|
email: anh.pham@infodation.vn
|
@@ -149,6 +169,7 @@ files:
|
|
149
169
|
- lib/itms_automation/javascript_handling_steps.rb
|
150
170
|
- lib/itms_automation/methods/assertion_methods.rb
|
151
171
|
- lib/itms_automation/methods/click_elements_methods.rb
|
172
|
+
- lib/itms_automation/methods/condition_methods.rb
|
152
173
|
- lib/itms_automation/methods/configuration_methods.rb
|
153
174
|
- lib/itms_automation/methods/error_handling_methods.rb
|
154
175
|
- lib/itms_automation/methods/input_methods.rb
|
@@ -158,6 +179,7 @@ files:
|
|
158
179
|
- lib/itms_automation/methods/progress_methods.rb
|
159
180
|
- lib/itms_automation/methods/required_files.rb
|
160
181
|
- lib/itms_automation/methods/screenshot_methods.rb
|
182
|
+
- lib/itms_automation/methods/store_methods.rb
|
161
183
|
- lib/itms_automation/navigation_steps.rb
|
162
184
|
- lib/itms_automation/progress_steps.rb
|
163
185
|
- lib/itms_automation/screenshot_steps.rb
|
@@ -181,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
203
|
- !ruby/object:Gem::Version
|
182
204
|
version: '0'
|
183
205
|
requirements: []
|
184
|
-
rubygems_version: 3.0.
|
206
|
+
rubygems_version: 3.0.3
|
185
207
|
signing_key:
|
186
208
|
specification_version: 4
|
187
209
|
summary: SELENIUM WEBDRIVER WITH RUBY & CUCUMBER
|