itms_automation 2.2 → 2.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/generate.rb +3 -37
- data/bin/helper.rb +23 -10
- data/bin/itms_automation +18 -23
- data/doc/installation.md +16 -0
- data/doc/itms-automation-API.md +103 -0
- data/doc/itms-automation-help.md +18 -0
- data/example/android/android_app/android_app_calculator.zip +0 -0
- data/example/android/android_app/android_app_calculator/AndroidCalculator.apk +0 -0
- data/example/android/android_app/android_app_calculator/features/calculator.feature +36 -0
- data/example/android/android_app/android_app_calculator/features/my_first.feature +13 -0
- data/example/android/android_app/android_app_calculator/features/screenshots/test.png +0 -0
- data/example/android/android_app/android_app_calculator/features/step_definitions/custom_steps.rb +5 -0
- data/example/android/android_app/android_app_calculator/features/support/env.rb +52 -0
- data/example/android/android_app/android_app_calculator/features/support/hooks.rb +26 -0
- data/example/android/android_web/android_web_gmail_login.zip +0 -0
- data/example/android/android_web/android_web_gmail_login/features/gmail_login.feature +12 -0
- data/example/android/android_web/android_web_gmail_login/features/my_first.feature +1 -0
- data/example/android/android_web/android_web_gmail_login/features/screenshots/test.png +0 -0
- data/example/android/android_web/android_web_gmail_login/features/step_definitions/custom_steps.rb +5 -0
- data/example/android/android_web/android_web_gmail_login/features/support/env.rb +51 -0
- data/example/android/android_web/android_web_gmail_login/features/support/hooks.rb +27 -0
- data/example/desktop web/desktop_web_gmail_login.zip +0 -0
- data/example/desktop web/desktop_web_gmail_login/features/gmail_login.feature +9 -0
- data/example/desktop web/desktop_web_gmail_login/features/gmail_multi_login.feature +21 -0
- data/example/desktop web/desktop_web_gmail_login/features/my_first.feature +1 -0
- data/example/desktop web/desktop_web_gmail_login/features/screenshots/test.png +0 -0
- data/example/desktop web/desktop_web_gmail_login/features/step_definitions/custom_steps.rb +5 -0
- data/example/desktop web/desktop_web_gmail_login/features/support/env.rb +106 -0
- data/example/desktop web/desktop_web_gmail_login/features/support/hooks.rb +38 -0
- data/features-skeleton/my_first.feature +5 -0
- data/features-skeleton/screenshots/test.png +0 -0
- data/features-skeleton/step_definitions/custom_steps.rb +5 -0
- data/features-skeleton/step_definitions/repositories/project_object.yml +1 -0
- data/features-skeleton/support/env.rb +106 -0
- data/features-skeleton/support/hooks.rb +38 -0
- data/lib/itms_automation.rb +1 -3
- data/lib/itms_automation/assertion_steps.rb +68 -0
- data/lib/itms_automation/click_elements_steps.rb +24 -0
- data/lib/itms_automation/configuration_steps.rb +7 -0
- data/lib/itms_automation/input_steps.rb +59 -0
- data/lib/itms_automation/javascript_handling_steps.rb +10 -0
- data/lib/itms_automation/methods/assertion_methods.rb +333 -0
- data/lib/itms_automation/methods/click_elements_methods.rb +23 -0
- data/lib/itms_automation/methods/configuration_methods.rb +35 -0
- data/lib/itms_automation/methods/error_handling_methods.rb +93 -0
- data/lib/itms_automation/methods/input_methods.rb +69 -0
- data/lib/itms_automation/methods/javascript_handling_methods.rb +9 -0
- data/lib/itms_automation/methods/misc_methods.rb +63 -0
- data/lib/itms_automation/methods/navigate_methods.rb +123 -0
- data/lib/itms_automation/methods/progress_methods.rb +15 -0
- data/lib/itms_automation/methods/required_files.rb +9 -0
- data/lib/itms_automation/methods/screenshot_methods.rb +6 -0
- data/lib/itms_automation/navigation_steps.rb +79 -0
- data/lib/itms_automation/progress_steps.rb +17 -0
- data/lib/itms_automation/screenshot_steps.rb +6 -0
- data/lib/itms_automation/version.rb +5 -3
- metadata +78 -94
- data/bin/console +0 -14
- data/bin/documentation_generator.rb +0 -119
- data/bin/setup +0 -8
- data/lib/itms_automation/all_steps.rb +0 -8
- data/lib/itms_automation/assertion_helper.rb +0 -29
- data/lib/itms_automation/auto_util.rb +0 -699
- data/lib/itms_automation/database_steps_helper.rb +0 -125
- data/lib/itms_automation/web_steps_helper.rb +0 -838
- data/project/Gemfile +0 -3
- data/project/README.md +0 -34
- data/project/Rakefile +0 -24
- data/project/config/chrome_headless_options.yaml +0 -1
- data/project/config/chrome_options.yaml +0 -6
- data/project/config/firefox_headless_options.yaml +0 -1
- data/project/config/firefox_options.yaml +0 -1
- data/project/config/ie_options.yaml +0 -1
- data/project/config/remote_options.yaml +0 -6
- data/project/config/safari_options.yaml +0 -1
- data/project/cucumber.yml +0 -4
- data/project/features/TestSuite/WebGUI.feature +0 -4
- data/project/features/step_definitions/lib_steps/steps_definition.rb +0 -3
- data/project/features/step_definitions/repositories/project_object.yml +0 -2
- data/project/features/support/env.rb +0 -10
- data/project/features/support/hooks.rb +0 -128
@@ -1,125 +0,0 @@
|
|
1
|
-
# require "active_record"
|
2
|
-
|
3
|
-
def create_database_connection(config)
|
4
|
-
start = Time.now
|
5
|
-
begin
|
6
|
-
if config.class === "String"
|
7
|
-
config = JSON.parse config
|
8
|
-
else
|
9
|
-
unless config.hashes.empty?
|
10
|
-
config = config.hashes[0]
|
11
|
-
config = JSON.parse(config) unless config.is_a? Hash
|
12
|
-
config.each_pair do |k, v|
|
13
|
-
config[k] = v
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
@connection = ActiveRecord::Base.establish_connection(config)
|
19
|
-
ActiveRecord::Base.connection.active?
|
20
|
-
|
21
|
-
if @connection.connected?
|
22
|
-
print_log("passed", start, __method__, config)
|
23
|
-
else
|
24
|
-
print_log("failed", start, __method__, config)
|
25
|
-
raise "Error: Can't connect to database"
|
26
|
-
end
|
27
|
-
rescue JSON::ParserError
|
28
|
-
print_log("failed", start, __method__, config)
|
29
|
-
raise "Error: Please check your connection configuration"
|
30
|
-
rescue Exception => e
|
31
|
-
print_log("failed", start, __method__, config)
|
32
|
-
raise "Error: #{e.message}"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def close_database_connection
|
37
|
-
start = Time.now
|
38
|
-
begin
|
39
|
-
@connection.disconnect!
|
40
|
-
print_log("passed", start, __method__)
|
41
|
-
rescue Exception => e
|
42
|
-
print_log("failed", start, __method__)
|
43
|
-
raise "Error: #{e.message}"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def execute_query(query)
|
48
|
-
start = Time.now
|
49
|
-
begin
|
50
|
-
if @connection.connected?
|
51
|
-
@result = @connection.connection.exec_query(query).to_a
|
52
|
-
print_log("passed", start, __method__, query)
|
53
|
-
else
|
54
|
-
print_log("failed", start, __method__, query)
|
55
|
-
raise "Error: Create connection to database first!"
|
56
|
-
end
|
57
|
-
rescue Exception => e
|
58
|
-
print_log("failed", start, __method__, query)
|
59
|
-
raise "Error: #{e.message}"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def print_sql_result
|
64
|
-
start = Time.now
|
65
|
-
if @result.present?
|
66
|
-
puts "SQL result:"
|
67
|
-
puts @result.to_json
|
68
|
-
else
|
69
|
-
puts "WARNING: No result from SQL statement"
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def verify_sql_result_contain(expected_string)
|
74
|
-
start = Time.now
|
75
|
-
begin
|
76
|
-
@expected = JSON.parse(expected_string)
|
77
|
-
is_contain = false
|
78
|
-
if @expected.kind_of?(Array) && @expected.length > @result.length
|
79
|
-
print_log("failed", start, __method__, expected_string)
|
80
|
-
raise "Error: Expected: #{@expected}\nGot: #{@result}\nQuery result not includes your expected"
|
81
|
-
end
|
82
|
-
@result.each do |row|
|
83
|
-
is_contain = do_assertion_json(@expected, row)
|
84
|
-
break if !@expected.kind_of?(Array) && is_contain == true
|
85
|
-
end
|
86
|
-
if is_contain
|
87
|
-
print_log("passed", start, __method__, expected_string)
|
88
|
-
else
|
89
|
-
print_log("failed", start, __method__, expected_string)
|
90
|
-
raise "Error: Expected: #{@expected}\nGot: #{@result}\nQuery result not includes your expected"
|
91
|
-
end
|
92
|
-
rescue JSON::ParserError
|
93
|
-
print_log("failed", start, __method__, expected_string)
|
94
|
-
raise "Error: Please check your expected"
|
95
|
-
rescue Exception => e
|
96
|
-
print_log("failed", start, __method__, expected_string)
|
97
|
-
raise "Error: #{e.message}"
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def verify_sql_result_equal(expected_string)
|
102
|
-
start = Time.now
|
103
|
-
begin
|
104
|
-
@expected = JSON.parse(expected_string)
|
105
|
-
if !@expected.kind_of?(Array) || @expected.length != @result.length
|
106
|
-
print_log("failed", start, __method__, expected_string)
|
107
|
-
raise "Error: Expected: #{@expected}\nGot: #{@result}\nQuery result not equal with your expected"
|
108
|
-
end
|
109
|
-
@result.each_with_index do |row, index|
|
110
|
-
is_contain = row.to_s == @expected[index].to_s
|
111
|
-
if is_contain
|
112
|
-
print_log("passed", start, __method__, expected_string)
|
113
|
-
else
|
114
|
-
print_log("failed", start, __method__, expected_string)
|
115
|
-
raise "Error: Expected: #{@expected}\nGot: #{@result}\nQuery result not equal with your expected"
|
116
|
-
end
|
117
|
-
end
|
118
|
-
rescue JSON::ParserError
|
119
|
-
print_log("failed", start, __method__, expected_string)
|
120
|
-
raise "Error: Please check your expected"
|
121
|
-
rescue Exception => e
|
122
|
-
print_log("failed", start, __method__, expected_string)
|
123
|
-
raise "Error: #{e.message}"
|
124
|
-
end
|
125
|
-
end
|
@@ -1,838 +0,0 @@
|
|
1
|
-
require "net/https"
|
2
|
-
require "rspec"
|
3
|
-
require "open-uri"
|
4
|
-
|
5
|
-
def execute_openbrowser(url_site)
|
6
|
-
start = Time.now
|
7
|
-
begin
|
8
|
-
if url_site == ""
|
9
|
-
print_log("failed", start, __method__, url_site)
|
10
|
-
raise "Error: Null web page URL."
|
11
|
-
end
|
12
|
-
visit(url_site)
|
13
|
-
print_log("passed", start, __method__, url_site)
|
14
|
-
rescue StandardError => e
|
15
|
-
print_log("failed", start, __method__, url_site)
|
16
|
-
raise "Error: #{e.message}"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def clear_cookie()
|
21
|
-
start = Time.now
|
22
|
-
begin
|
23
|
-
browser = Capybara.current_session.driver.browser
|
24
|
-
if browser.respond_to?(:clear_cookies)
|
25
|
-
# Rack::MockSession
|
26
|
-
browser.clear_cookies
|
27
|
-
print_log("passed", start, __method__)
|
28
|
-
elsif browser.respond_to?(:manage) and browser.manage.respond_to?(:delete_all_cookies)
|
29
|
-
# Selenium::WebDriver
|
30
|
-
browser.manage.delete_all_cookies
|
31
|
-
print_log("passed", start, __method__)
|
32
|
-
else
|
33
|
-
print_log("failed", start, __method__)
|
34
|
-
raise "Error: Don't know how to clear cookies. Weird driver?"
|
35
|
-
end
|
36
|
-
rescue Exception => e
|
37
|
-
print_log("failed", start, __method__)
|
38
|
-
raise "Error: #{e.message}"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def execute_click(element)
|
43
|
-
start = Time.now
|
44
|
-
foundElement = find_object(element)
|
45
|
-
if foundElement != nil
|
46
|
-
begin
|
47
|
-
foundElement.click
|
48
|
-
print_log("passed", start, __method__, element)
|
49
|
-
rescue StandardError => e
|
50
|
-
print_log("failed", start, __method__, element)
|
51
|
-
raise "Error: #{e.message}"
|
52
|
-
end
|
53
|
-
else
|
54
|
-
print_log("failed", start, __method__, element)
|
55
|
-
raise "Error: Not found object #{element}"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def execute_click_offset(element, x, y)
|
60
|
-
start = Time.now
|
61
|
-
foundElement = find_object(element)
|
62
|
-
if foundElement != nil
|
63
|
-
begin
|
64
|
-
page.driver.browser.mouse.move_to(foundElement.native, x.to_i, y.to_i)
|
65
|
-
page.driver.browser.mouse.click()
|
66
|
-
print_log("passed", start, __method__, element, x, y)
|
67
|
-
rescue Exception => e
|
68
|
-
print_log("failed", start, __method__, element, x, y)
|
69
|
-
raise "Error: #{e.message}"
|
70
|
-
end
|
71
|
-
else
|
72
|
-
print_log("failed", start, __method__, element, x, y)
|
73
|
-
raise "Error: Not found object: #{element}"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def double_click(element)
|
78
|
-
start = Time.now
|
79
|
-
foundElement = find_object(element)
|
80
|
-
if foundElement != nil
|
81
|
-
begin
|
82
|
-
foundElement.double_click
|
83
|
-
print_log("passed", start, __method__, element)
|
84
|
-
rescue StandardError => e
|
85
|
-
print_log("failed", start, __method__, element)
|
86
|
-
raise "Error: #{e.message}"
|
87
|
-
end
|
88
|
-
else
|
89
|
-
print_log("failed", start, __method__, element)
|
90
|
-
raise "Error: Not found object: #{element}"
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def execute_settext(element, text)
|
95
|
-
start = Time.now
|
96
|
-
foundElement = find_object(element)
|
97
|
-
if foundElement != nil
|
98
|
-
begin
|
99
|
-
foundElement.set(text)
|
100
|
-
print_log("passed", start, __method__, element, text)
|
101
|
-
rescue StandardError => e
|
102
|
-
print_log("failed", start, __method__, element, text)
|
103
|
-
raise "Error: #{e.message}"
|
104
|
-
end
|
105
|
-
else
|
106
|
-
print_log("failed", start, __method__, element, text)
|
107
|
-
raise "Error: Not found object: #{element}"
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def maximize_browser
|
112
|
-
start = Time.now
|
113
|
-
begin
|
114
|
-
page.driver.browser.manage.window.maximize
|
115
|
-
print_log("passed", start, __method__)
|
116
|
-
rescue StandardError => e
|
117
|
-
print_log("failed", start, __method__)
|
118
|
-
raise "Error: #{e.message}"
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def switch_to_window_by_title(window_title)
|
123
|
-
start = Time.now
|
124
|
-
$previous_window = page.driver.browser.window_handle
|
125
|
-
@window_found = false
|
126
|
-
page.driver.browser.window_handles.each { |handle|
|
127
|
-
page.driver.browser.switch_to.window handle
|
128
|
-
if page.title == window_title
|
129
|
-
@window_found = true
|
130
|
-
print_log("passed", start, __method__, window_title)
|
131
|
-
break
|
132
|
-
end
|
133
|
-
}
|
134
|
-
if @window_found == false
|
135
|
-
print_log("failed", start, __method__, window_title)
|
136
|
-
raise "Error: Window having title \"#{window_title}\" not found"
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
def scroll_to_end_page
|
141
|
-
start = Time.now
|
142
|
-
begin
|
143
|
-
page.driver.execute_script("window.scrollTo(0,Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight));")
|
144
|
-
print_log("passed", start, __method__)
|
145
|
-
rescue StandardError => e
|
146
|
-
print_log("failed", start, __method__)
|
147
|
-
raise "Error: #{e.message}"
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
def scroll_to_top_page
|
152
|
-
start = Time.now
|
153
|
-
begin
|
154
|
-
page.driver.execute_script("window.scrollTo(Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight),0);")
|
155
|
-
print_log("passed", start, __method__)
|
156
|
-
rescue StandardError => e
|
157
|
-
print_log("failed", start, __method__)
|
158
|
-
raise "Error: #{e.message}"
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
def verify_title(expected_title)
|
163
|
-
start = Time.now
|
164
|
-
begin
|
165
|
-
page_title = page.title
|
166
|
-
expect(page_title).to eq expected_title
|
167
|
-
print_log("passed", start, __method__, expected_title)
|
168
|
-
puts "Actual Page Title : #{page_title}, Expected Page Title : #{expected_title}"
|
169
|
-
rescue StandardError => e
|
170
|
-
print_log("failed", start, __method__, expected_title)
|
171
|
-
raise "Error: #{e.message}"
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
def verify_alert_text(text)
|
176
|
-
start = Time.now
|
177
|
-
begin
|
178
|
-
alert = page.driver.browser.switch_to.alert.text
|
179
|
-
expect(alert).to eq text
|
180
|
-
print_log("passed", start, __method__, text)
|
181
|
-
puts "Actual Page alert text : #{alert}, Expected value : #{text}"
|
182
|
-
rescue StandardError => e
|
183
|
-
print_log("failed", start, __method__, text)
|
184
|
-
raise "Error: #{e.message}"
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
def accept_alert
|
189
|
-
start = Time.now
|
190
|
-
begin
|
191
|
-
page.driver.browser.switch_to.alert.accept
|
192
|
-
print_log("passed", start, __method__)
|
193
|
-
rescue Exception => e
|
194
|
-
print_log("failed", start, __method__)
|
195
|
-
raise "Error: #{e.message}"
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
def back
|
200
|
-
start = Time.now
|
201
|
-
begin
|
202
|
-
page.execute_script("window.history.back()")
|
203
|
-
print_log("passed", start, __method__)
|
204
|
-
rescue Exception => e
|
205
|
-
print_log("failed", start, __method__)
|
206
|
-
raise "Error: #{e.message}"
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
def refresh
|
211
|
-
start = Time.now
|
212
|
-
begin
|
213
|
-
page.execute_script("window.location.reload()")
|
214
|
-
print_log("passed", start, __method__)
|
215
|
-
rescue Exception => e
|
216
|
-
print_log("failed", start, __method__)
|
217
|
-
raise "Error: #{e.message}"
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
def clear_text(element)
|
222
|
-
start = Time.now
|
223
|
-
foundElement = find_object(element)
|
224
|
-
if foundElement != nil?
|
225
|
-
begin
|
226
|
-
foundElement.native.clear
|
227
|
-
print_log("passed", start, __method__, element)
|
228
|
-
rescue Exception => e
|
229
|
-
print_log("failed", start, __method__, element)
|
230
|
-
raise "Error: #{e.message}"
|
231
|
-
end
|
232
|
-
else
|
233
|
-
print_log("failed", start, __method__, element)
|
234
|
-
raise "Error: Not found object: #{element}"
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
def execute_javascript(script)
|
239
|
-
start = Time.now
|
240
|
-
begin
|
241
|
-
page.execute_script(script)
|
242
|
-
print_log("passed", start, __method__, script)
|
243
|
-
rescue Exception => e
|
244
|
-
print_log("failed", start, __method__, script)
|
245
|
-
raise "Error: Not found object: #{element}"
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
def execute_select(element, option)
|
250
|
-
start = Time.now
|
251
|
-
foundElement = find_object(element)
|
252
|
-
if foundElement != nil
|
253
|
-
begin
|
254
|
-
foundElement.find("option", text: option).select_option
|
255
|
-
print_log("passed", start, __method__, element, option)
|
256
|
-
rescue Exception => e
|
257
|
-
print_log("failed", start, __method__, element, option)
|
258
|
-
raise "Error: #{e.message}"
|
259
|
-
end
|
260
|
-
else
|
261
|
-
print_log("failed", start, __method__, element, option)
|
262
|
-
raise "Error: Not found object: #{element}"
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
def execute_mouse_over(element)
|
267
|
-
start = Time.now
|
268
|
-
foundElement = find_object(element)
|
269
|
-
if foundElement != nil
|
270
|
-
begin
|
271
|
-
page.driver.browser.action.move_to(foundElement.native, element).click.perform
|
272
|
-
print_log("passed", start, __method__, element)
|
273
|
-
sleep(1)
|
274
|
-
rescue StandardError => e
|
275
|
-
print_log("failed", start, __method__, element)
|
276
|
-
raise "Error: #{e.message}"
|
277
|
-
end
|
278
|
-
else
|
279
|
-
print_log("failed", start, __method__, element)
|
280
|
-
raise "Error: Not found object: #{element}"
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
284
|
-
def remove_element_attribute(element, attr)
|
285
|
-
start = Time.now
|
286
|
-
foundElement = find_object(element)
|
287
|
-
if foundElement != nil
|
288
|
-
begin
|
289
|
-
page.driver.browser.execute_script("arguments[0].removeAttribute('#{attr}');", foundElement.native)
|
290
|
-
print_log("passed", start, __method__, element, attr)
|
291
|
-
sleep(1)
|
292
|
-
rescue StandardError => e
|
293
|
-
print_log("failed", start, __method__, element, attr)
|
294
|
-
raise "Error: #{e.message}"
|
295
|
-
end
|
296
|
-
else
|
297
|
-
print_log("failed", start, __method__, element, attr)
|
298
|
-
raise "Error: Not found object: #{element}"
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
# Set state
|
303
|
-
def execute_setstate(element, state)
|
304
|
-
start = Time.now
|
305
|
-
foundElement = find_object(element)
|
306
|
-
if foundElement != nil
|
307
|
-
if state
|
308
|
-
foundElement.select_option
|
309
|
-
else
|
310
|
-
foundElement.unselect_option
|
311
|
-
end
|
312
|
-
print_log("passed", start, __method__, element, state)
|
313
|
-
else
|
314
|
-
print_log("failed", start, __method__, element, state)
|
315
|
-
raise "Error: Not found object: #{element}"
|
316
|
-
end
|
317
|
-
end
|
318
|
-
|
319
|
-
def close_windows
|
320
|
-
start = Time.now
|
321
|
-
begin
|
322
|
-
page.execute_script "window.close();"
|
323
|
-
print_log("passed", start, __method__)
|
324
|
-
rescue StandardError => e
|
325
|
-
print_log("failed", start, __method__)
|
326
|
-
raise "Error: #{e.message}"
|
327
|
-
end
|
328
|
-
end
|
329
|
-
|
330
|
-
def resize_window_screen(x, y)
|
331
|
-
start = Time.now
|
332
|
-
begin
|
333
|
-
page.driver.browser.manage.window.resize_to(x, y)
|
334
|
-
print_log("passed", start, __method__, x, y)
|
335
|
-
rescue StandardError => e
|
336
|
-
print_log("failed", start, __method__, x, y)
|
337
|
-
raise "Error: #{e.message}"
|
338
|
-
end
|
339
|
-
end
|
340
|
-
|
341
|
-
def switch_to_iframe(element)
|
342
|
-
start = Time.now
|
343
|
-
foundElement = find_object(element)
|
344
|
-
if foundElement != nil
|
345
|
-
begin
|
346
|
-
page.driver.switch_to_frame(foundElement)
|
347
|
-
print_log("passed", start, __method__, element)
|
348
|
-
rescue Exception => e
|
349
|
-
print_log("failed", start, __method__, element)
|
350
|
-
raise "Error: #{e.message}"
|
351
|
-
end
|
352
|
-
else
|
353
|
-
print_log("failed", start, __method__, element)
|
354
|
-
raise "Error: Not found object #{element}"
|
355
|
-
end
|
356
|
-
end
|
357
|
-
|
358
|
-
def switch_to_default_content
|
359
|
-
start = Time.now
|
360
|
-
begin
|
361
|
-
page.driver.browser.switch_to.default_content
|
362
|
-
print_log("passed", start, __method__)
|
363
|
-
rescue Exception => e
|
364
|
-
print_log("failed", start, __method__)
|
365
|
-
raise "Error: #{e.message}"
|
366
|
-
end
|
367
|
-
end
|
368
|
-
|
369
|
-
def get_computed_style(element, style)
|
370
|
-
start = Time.now
|
371
|
-
foundElement = get_object_value(element)
|
372
|
-
computedStyle = ""
|
373
|
-
if foundElement != nil
|
374
|
-
computedStyle = page.evaluate_script("window.getComputedStyle(document.querySelector('#{foundElement}')).#{style}")
|
375
|
-
else
|
376
|
-
print_log("failed", start, __method__, element, style)
|
377
|
-
raise "Error: Not found object: #{element}"
|
378
|
-
end
|
379
|
-
print_log("passed", start, __method__, element, style)
|
380
|
-
puts "Actual object style value is: #{computedStyle}"
|
381
|
-
computedStyle
|
382
|
-
end
|
383
|
-
|
384
|
-
def get_element_text(element)
|
385
|
-
start = Time.now
|
386
|
-
foundElement = find_object(element)
|
387
|
-
if foundElement != nil
|
388
|
-
begin
|
389
|
-
result = foundElement.text()
|
390
|
-
print_log("passed", start, __method__, element)
|
391
|
-
puts "Text of #{element}: #{result}"
|
392
|
-
rescue StandardError => e
|
393
|
-
print_log("failed", start, __method__, element)
|
394
|
-
raise "Error: #{e.message}"
|
395
|
-
end
|
396
|
-
else
|
397
|
-
print_log("failed", start, __method__, element)
|
398
|
-
raise "Error: Not found object: #{element}"
|
399
|
-
end
|
400
|
-
end
|
401
|
-
|
402
|
-
def get_element_attribute(element)
|
403
|
-
start = Time.now
|
404
|
-
foundElement = find_object(element)
|
405
|
-
if foundElement != nil
|
406
|
-
begin
|
407
|
-
result = foundElement.value()
|
408
|
-
print_log("passed", start, __method__, element)
|
409
|
-
puts "Attribute of #{element}: #{result}"
|
410
|
-
rescue StandardError => e
|
411
|
-
print_log("failed", start, __method__, element)
|
412
|
-
raise "Error: #{e.message}"
|
413
|
-
end
|
414
|
-
else
|
415
|
-
print_log("failed", start, __method__, element, value)
|
416
|
-
raise "Error: Not found object: #{element}"
|
417
|
-
end
|
418
|
-
end
|
419
|
-
|
420
|
-
def verify_element_text(element, value)
|
421
|
-
start = Time.now
|
422
|
-
foundElement = find_object(element)
|
423
|
-
if foundElement != nil
|
424
|
-
begin
|
425
|
-
actual_value = foundElement.text()
|
426
|
-
expect(actual_value).to eq value
|
427
|
-
print_log("passed", start, __method__, element, value)
|
428
|
-
rescue Exception => e
|
429
|
-
print_log("failed", start, __method__, element, value)
|
430
|
-
raise "Error: #{e.message}"
|
431
|
-
end
|
432
|
-
else
|
433
|
-
print_log("failed", start, __method__, element, value)
|
434
|
-
raise "Error: Not found object: #{element}"
|
435
|
-
end
|
436
|
-
end
|
437
|
-
|
438
|
-
def verify_element_not_has_text(element, value)
|
439
|
-
start = Time.now
|
440
|
-
foundElement = find_object(element)
|
441
|
-
if foundElement != nil
|
442
|
-
begin
|
443
|
-
actual_value = foundElement.text()
|
444
|
-
expect(actual_value).not_to eql value
|
445
|
-
print_log("passed", start, __method__, element, value)
|
446
|
-
rescue Exception => e
|
447
|
-
print_log("failed", start, __method__, element, value)
|
448
|
-
raise "Error: #{e.message}"
|
449
|
-
end
|
450
|
-
else
|
451
|
-
print_log("failed", start, __method__, element, value)
|
452
|
-
raise "Error: Not found object: #{element}"
|
453
|
-
end
|
454
|
-
end
|
455
|
-
|
456
|
-
def verify_element_value(element, value)
|
457
|
-
start = Time.now
|
458
|
-
foundElement = find_object(element)
|
459
|
-
if foundElement != nil
|
460
|
-
begin
|
461
|
-
actual_value = foundElement.value()
|
462
|
-
expect(actual_value).to eq value
|
463
|
-
print_log("passed", start, __method__, element, value)
|
464
|
-
rescue Exception => e
|
465
|
-
print_log("failed", start, __method__, element, value)
|
466
|
-
raise "Error: #{e.message}"
|
467
|
-
end
|
468
|
-
else
|
469
|
-
print_log("failed", start, __method__, element, value)
|
470
|
-
raise "Error: Not found object: #{element}"
|
471
|
-
end
|
472
|
-
end
|
473
|
-
|
474
|
-
def verify_element_not_has_value(element, value)
|
475
|
-
start = Time.now
|
476
|
-
foundElement = find_object(element)
|
477
|
-
if foundElement != nil
|
478
|
-
begin
|
479
|
-
actual_value = foundElement.value()
|
480
|
-
expect(actual_value).not_to eql value
|
481
|
-
print_log("passed", start, __method__, element, value)
|
482
|
-
rescue Exception => e
|
483
|
-
print_log("failed", start, __method__, element, value)
|
484
|
-
raise "Error: #{e.message}"
|
485
|
-
end
|
486
|
-
else
|
487
|
-
print_log("failed", start, __method__, element, value)
|
488
|
-
raise "Error: Not found object: #{element}"
|
489
|
-
end
|
490
|
-
end
|
491
|
-
|
492
|
-
def execute_checkproperty(element, property, negate, value, isSpecialChar = false)
|
493
|
-
start = Time.now
|
494
|
-
validate_option_by(property)
|
495
|
-
Capybara.configure do |config|
|
496
|
-
config.ignore_hidden_elements = false
|
497
|
-
end
|
498
|
-
foundElement = find_object(element)
|
499
|
-
|
500
|
-
check = false
|
501
|
-
if foundElement == nil and value == ""
|
502
|
-
check = true
|
503
|
-
# check.should eq true
|
504
|
-
expect(check).to eq true
|
505
|
-
else
|
506
|
-
if foundElement != nil
|
507
|
-
if property.upcase == "VALUE"
|
508
|
-
actual_value = foundElement.value()
|
509
|
-
elsif property.upcase == "TEXT"
|
510
|
-
actual_value = foundElement.text()
|
511
|
-
else
|
512
|
-
actual_value = foundElement["#{property}"]
|
513
|
-
end
|
514
|
-
|
515
|
-
if actual_value == nil
|
516
|
-
actual_value = ""
|
517
|
-
end
|
518
|
-
else
|
519
|
-
print_log("failed", start, __method__, element, property, negate, value, isSpecialChar)
|
520
|
-
raise "Error: Not found object: #{element}"
|
521
|
-
end
|
522
|
-
|
523
|
-
Capybara.configure do |config|
|
524
|
-
config.ignore_hidden_elements = true
|
525
|
-
end
|
526
|
-
|
527
|
-
# if IFD_Assertion.reg_compare(actual_value, value, isSpecialChar)
|
528
|
-
# check = true
|
529
|
-
# end
|
530
|
-
|
531
|
-
begin
|
532
|
-
if negate == " not"
|
533
|
-
actual_value.should_not eq value
|
534
|
-
expect(actual_value).not_to eql value
|
535
|
-
elsif actual_value.should eq value
|
536
|
-
expect(actual_value).to eq value
|
537
|
-
end
|
538
|
-
print_log("passed", start, __method__, element, property, negate, value, isSpecialChar)
|
539
|
-
rescue Exception => e
|
540
|
-
print_log("failed", start, __method__, element, property, negate, value, isSpecialChar)
|
541
|
-
raise "Error: #{e.message}"
|
542
|
-
end
|
543
|
-
end
|
544
|
-
end
|
545
|
-
|
546
|
-
def get_object_and_store_as_string(object, string)
|
547
|
-
text = execute_gettext(object)
|
548
|
-
txt = "'" + text + "'"
|
549
|
-
set_var(string, txt)
|
550
|
-
end
|
551
|
-
|
552
|
-
def get_object_and_store_to_file(object, file_name)
|
553
|
-
$text = execute_gettext(object)
|
554
|
-
open($test_data_dir + file_name, "a+") do |f|
|
555
|
-
f << $text + "\n"
|
556
|
-
end
|
557
|
-
end
|
558
|
-
|
559
|
-
def drag_and_drop_by_offset(element, x, y)
|
560
|
-
start = Time.now
|
561
|
-
foundElement = find_object(element)
|
562
|
-
if foundElement != nil
|
563
|
-
begin
|
564
|
-
page.driver.browser.action.drag_and_drop_by(foundElement, x, y).perform
|
565
|
-
print_log("passed", start, __method__, element, x, y)
|
566
|
-
rescue Exception => e
|
567
|
-
print_log("failed", start, __method__, element, x, y)
|
568
|
-
raise "Error: #{e.message}"
|
569
|
-
end
|
570
|
-
else
|
571
|
-
print_log("failed", start, __method__, element, x, y)
|
572
|
-
raise "Error: Not found object: #{element}"
|
573
|
-
end
|
574
|
-
end
|
575
|
-
|
576
|
-
def drag_and_drop_to_object(from_element, element)
|
577
|
-
start = Time.now
|
578
|
-
found_from_element = find_object(from_element)
|
579
|
-
foundElement = find_object(element)
|
580
|
-
if foundElement != nil and found_from_element != nil
|
581
|
-
found_from_element.drag_to(foundElement)
|
582
|
-
print_log("passed", start, __method__, from_element, element)
|
583
|
-
end
|
584
|
-
end
|
585
|
-
|
586
|
-
def execute_sendkeys(element, key)
|
587
|
-
start = Time.now
|
588
|
-
validate_supported_keys(key)
|
589
|
-
foundElement = find_object(element)
|
590
|
-
if foundElement != nil
|
591
|
-
begin
|
592
|
-
foundElement.native.send_keys(key)
|
593
|
-
print_log("passed", start, __method__, element, key)
|
594
|
-
rescue Exception => e
|
595
|
-
print_log("failed", start, __method__, element, key)
|
596
|
-
raise "Error: #{e.message}"
|
597
|
-
end
|
598
|
-
else
|
599
|
-
print_log("failed", start, __method__, element, key)
|
600
|
-
raise "Error: Not found object: #{element}"
|
601
|
-
end
|
602
|
-
end
|
603
|
-
|
604
|
-
def movemouseandclick(var, element)
|
605
|
-
Selenium::WebDriver::Support::Select.new(page.driver.browser.find_element(:id, "#{var}")).select_by(:text, "#{element}")
|
606
|
-
page.driver.browser.find_element(:id, "#{var}").click
|
607
|
-
end
|
608
|
-
|
609
|
-
def upload_file(element, file_url)
|
610
|
-
start = Time.now
|
611
|
-
found_element = find_object(element)
|
612
|
-
if found_element != nil
|
613
|
-
begin
|
614
|
-
file_name = File.basename(file_url)
|
615
|
-
FileUtils.mkdir_p("downloads") unless File.exist?("downloads")
|
616
|
-
File.open("downloads/#{file_name}", "wb") do |file|
|
617
|
-
file.write open(file_url).read
|
618
|
-
end
|
619
|
-
attach_file(found_element, "downloads/#{file_name}")
|
620
|
-
print_log("passed", start, __method__, element, file_url)
|
621
|
-
rescue StandardError => e
|
622
|
-
print_log("failed", start, __method__, element, file_url)
|
623
|
-
raise "Error: #{e.message}"
|
624
|
-
end
|
625
|
-
else
|
626
|
-
print_log("failed", start, __method__, element, file_url)
|
627
|
-
raise "Error: Not found object: #{element}"
|
628
|
-
end
|
629
|
-
end
|
630
|
-
|
631
|
-
def store_variable(var_name, var_value)
|
632
|
-
start = Time.now
|
633
|
-
begin
|
634
|
-
text = "'" + var_value + "'"
|
635
|
-
set_var(var_name, text)
|
636
|
-
print_log("passed", start, __method__, var_name, var_value)
|
637
|
-
rescue StandardError => e
|
638
|
-
print_log("failed", start, __method__, var_name, var_value)
|
639
|
-
raise "Error: #{e.message}"
|
640
|
-
end
|
641
|
-
end
|
642
|
-
|
643
|
-
def store_text_element(element, var_name)
|
644
|
-
start = Time.now
|
645
|
-
found_element = find_object(element)
|
646
|
-
if found_element != nil
|
647
|
-
begin
|
648
|
-
var_value = "'" + found_element.text() + "'"
|
649
|
-
set_var(var_name, var_value)
|
650
|
-
print_log("passed", start, __method__, element, var_name)
|
651
|
-
rescue StandardError => e
|
652
|
-
print_log("failed", start, __method__, element, var_name)
|
653
|
-
raise "Error: #{e.message}"
|
654
|
-
end
|
655
|
-
else
|
656
|
-
print_log("failed", start, __method__, element, var_name)
|
657
|
-
raise "Error: Not found object: #{element}"
|
658
|
-
end
|
659
|
-
end
|
660
|
-
|
661
|
-
def store_title_current_page(var_name)
|
662
|
-
start = Time.now
|
663
|
-
begin
|
664
|
-
var_value = "'" + page.title + "'"
|
665
|
-
set_var(var_name, var_value)
|
666
|
-
print_log("passed", start, __method__, var_name)
|
667
|
-
rescue StandardError => e
|
668
|
-
print_log("failed", start, __method__, var_name)
|
669
|
-
raise "Error: #{e.message}"
|
670
|
-
end
|
671
|
-
end
|
672
|
-
|
673
|
-
def store_element_value(element, var_name)
|
674
|
-
start = Time.now
|
675
|
-
found_element = find_object(element)
|
676
|
-
if found_element != nil
|
677
|
-
begin
|
678
|
-
var_value = "'" + found_element.value() + "'"
|
679
|
-
set_var(var_name, var_value)
|
680
|
-
print_log("passed", start, __method__, element, var_name)
|
681
|
-
rescue StandardError => e
|
682
|
-
print_log("failed", start, __method__, element, var_name)
|
683
|
-
raise "Error: #{e.message}"
|
684
|
-
end
|
685
|
-
else
|
686
|
-
print_log("failed", start, __method__, element, var_name)
|
687
|
-
raise "Error: Not found object: #{element}"
|
688
|
-
end
|
689
|
-
end
|
690
|
-
|
691
|
-
def store_element_attribute_value(element, attribute, var_name)
|
692
|
-
start = Time.now
|
693
|
-
found_element = find_object(element)
|
694
|
-
if found_element != nil
|
695
|
-
begin
|
696
|
-
var_value = "'" + found_element[attribute] + "'"
|
697
|
-
set_var(var_name, var_value)
|
698
|
-
print_log("passed", start, __method__, element, var_name)
|
699
|
-
rescue StandardError => e
|
700
|
-
print_log("failed", start, __method__, element, var_name)
|
701
|
-
raise "Error: #{e.message}"
|
702
|
-
end
|
703
|
-
else
|
704
|
-
print_log("failed", start, __method__, element, var_name)
|
705
|
-
raise "Error: Not found object: #{element}"
|
706
|
-
end
|
707
|
-
end
|
708
|
-
|
709
|
-
def store_evaluate_script(script, var_name)
|
710
|
-
start = Time.now
|
711
|
-
begin
|
712
|
-
result = page.evaluate_script(<<~JS, script)
|
713
|
-
(function(scr){
|
714
|
-
return eval(scr);
|
715
|
-
})(arguments[0])
|
716
|
-
JS
|
717
|
-
var_value = "'" + result.to_s + "'"
|
718
|
-
set_var(var_name, var_value)
|
719
|
-
print_log("passed", start, __method__, script, var_name)
|
720
|
-
rescue StandardError => e
|
721
|
-
print_log("failed", start, __method__, script, var_name)
|
722
|
-
raise "Error: #{e.message}"
|
723
|
-
end
|
724
|
-
end
|
725
|
-
|
726
|
-
def check_checkbox_radio(element)
|
727
|
-
start = Time.now
|
728
|
-
found_element = find_object(element)
|
729
|
-
if found_element != nil
|
730
|
-
begin
|
731
|
-
found_element.check(allow_label_click: true)
|
732
|
-
print_log("passed", start, __method__, element)
|
733
|
-
rescue StandardError => e
|
734
|
-
print_log("failed", start, __method__, element)
|
735
|
-
raise "Error: #{e.message}"
|
736
|
-
end
|
737
|
-
else
|
738
|
-
print_log("failed", start, __method__, element)
|
739
|
-
raise "Error: Not found object: #{element}"
|
740
|
-
end
|
741
|
-
end
|
742
|
-
|
743
|
-
def uncheck_checkbox_radio(element)
|
744
|
-
start = Time.now
|
745
|
-
found_element = find_object(element)
|
746
|
-
if found_element != nil
|
747
|
-
begin
|
748
|
-
found_element.uncheck(allow_label_click: true)
|
749
|
-
print_log("passed", start, __method__, element)
|
750
|
-
rescue StandardError => e
|
751
|
-
print_log("failed", start, __method__, element)
|
752
|
-
raise "Error: #{e.message}"
|
753
|
-
end
|
754
|
-
else
|
755
|
-
print_log("failed", start, __method__, element)
|
756
|
-
raise "Error: Not found object: #{element}"
|
757
|
-
end
|
758
|
-
end
|
759
|
-
|
760
|
-
def verify_checkbox_radio_checked(element)
|
761
|
-
start = Time.now
|
762
|
-
found_element = find_object(element)
|
763
|
-
if found_element != nil
|
764
|
-
begin
|
765
|
-
if found_element.checked?
|
766
|
-
print_log("passed", start, __method__, element)
|
767
|
-
else
|
768
|
-
print_log("failed", start, __method__, element)
|
769
|
-
end
|
770
|
-
rescue StandardError => e
|
771
|
-
print_log("failed", start, __method__, element)
|
772
|
-
raise "Error: #{e.message}"
|
773
|
-
end
|
774
|
-
else
|
775
|
-
print_log("failed", start, __method__, element)
|
776
|
-
raise "Error: Not found object: #{element}"
|
777
|
-
end
|
778
|
-
end
|
779
|
-
|
780
|
-
def verify_checkbox_radio_not_checked(element)
|
781
|
-
start = Time.now
|
782
|
-
found_element = find_object(element)
|
783
|
-
if found_element != nil
|
784
|
-
begin
|
785
|
-
if found_element.checked?
|
786
|
-
print_log("failed", start, __method__, element)
|
787
|
-
else
|
788
|
-
print_log("passed", start, __method__, element)
|
789
|
-
end
|
790
|
-
rescue StandardError => e
|
791
|
-
print_log("failed", start, __method__, element)
|
792
|
-
raise "Error: #{e.message}"
|
793
|
-
end
|
794
|
-
else
|
795
|
-
print_log("failed", start, __method__, element)
|
796
|
-
raise "Error: Not found object: #{element}"
|
797
|
-
end
|
798
|
-
end
|
799
|
-
|
800
|
-
def verify_input_editable(element)
|
801
|
-
start = Time.now
|
802
|
-
found_element = find_object(element)
|
803
|
-
if found_element != nil
|
804
|
-
begin
|
805
|
-
if found_element.disabled?
|
806
|
-
print_log("passed", start, __method__, element)
|
807
|
-
else
|
808
|
-
print_log("failed", start, __method__, element)
|
809
|
-
end
|
810
|
-
rescue StandardError => e
|
811
|
-
print_log("failed", start, __method__, element)
|
812
|
-
raise "Error: #{e.message}"
|
813
|
-
end
|
814
|
-
else
|
815
|
-
print_log("failed", start, __method__, element)
|
816
|
-
raise "Error: Not found object: #{element}"
|
817
|
-
end
|
818
|
-
end
|
819
|
-
|
820
|
-
def verify_input_not_editable(element)
|
821
|
-
start = Time.now
|
822
|
-
found_element = find_object(element)
|
823
|
-
if found_element != nil
|
824
|
-
begin
|
825
|
-
if found_element.disabled?
|
826
|
-
print_log("failed", start, __method__, element)
|
827
|
-
else
|
828
|
-
print_log("passed", start, __method__, element)
|
829
|
-
end
|
830
|
-
rescue StandardError => e
|
831
|
-
print_log("failed", start, __method__, element)
|
832
|
-
raise "Error: #{e.message}"
|
833
|
-
end
|
834
|
-
else
|
835
|
-
print_log("failed", start, __method__, element)
|
836
|
-
raise "Error: Not found object: #{element}"
|
837
|
-
end
|
838
|
-
end
|