itms_automation 2.3 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/bin/generate.rb +3 -37
  3. data/bin/helper.rb +23 -10
  4. data/bin/itms_automation +18 -23
  5. data/doc/installation.md +16 -0
  6. data/doc/itms-automation-API.md +103 -0
  7. data/doc/itms-automation-help.md +18 -0
  8. data/example/android/android_app/android_app_calculator.zip +0 -0
  9. data/example/android/android_app/android_app_calculator/AndroidCalculator.apk +0 -0
  10. data/example/android/android_app/android_app_calculator/features/calculator.feature +36 -0
  11. data/example/android/android_app/android_app_calculator/features/my_first.feature +13 -0
  12. data/example/android/android_app/android_app_calculator/features/screenshots/test.png +0 -0
  13. data/example/android/android_app/android_app_calculator/features/step_definitions/custom_steps.rb +5 -0
  14. data/example/android/android_app/android_app_calculator/features/support/env.rb +52 -0
  15. data/example/android/android_app/android_app_calculator/features/support/hooks.rb +26 -0
  16. data/example/android/android_web/android_web_gmail_login.zip +0 -0
  17. data/example/android/android_web/android_web_gmail_login/features/gmail_login.feature +12 -0
  18. data/example/android/android_web/android_web_gmail_login/features/my_first.feature +1 -0
  19. data/example/android/android_web/android_web_gmail_login/features/screenshots/test.png +0 -0
  20. data/example/android/android_web/android_web_gmail_login/features/step_definitions/custom_steps.rb +5 -0
  21. data/example/android/android_web/android_web_gmail_login/features/support/env.rb +51 -0
  22. data/example/android/android_web/android_web_gmail_login/features/support/hooks.rb +27 -0
  23. data/example/desktop web/desktop_web_gmail_login.zip +0 -0
  24. data/example/desktop web/desktop_web_gmail_login/features/gmail_login.feature +9 -0
  25. data/example/desktop web/desktop_web_gmail_login/features/gmail_multi_login.feature +21 -0
  26. data/example/desktop web/desktop_web_gmail_login/features/my_first.feature +1 -0
  27. data/example/desktop web/desktop_web_gmail_login/features/screenshots/test.png +0 -0
  28. data/example/desktop web/desktop_web_gmail_login/features/step_definitions/custom_steps.rb +5 -0
  29. data/example/desktop web/desktop_web_gmail_login/features/support/env.rb +106 -0
  30. data/example/desktop web/desktop_web_gmail_login/features/support/hooks.rb +38 -0
  31. data/features-skeleton/my_first.feature +5 -0
  32. data/features-skeleton/screenshots/test.png +0 -0
  33. data/features-skeleton/step_definitions/custom_steps.rb +5 -0
  34. data/features-skeleton/step_definitions/repositories/project_object.yml +1 -0
  35. data/features-skeleton/support/env.rb +108 -0
  36. data/features-skeleton/support/hooks.rb +38 -0
  37. data/lib/itms_automation.rb +1 -3
  38. data/lib/itms_automation/assertion_steps.rb +68 -0
  39. data/lib/itms_automation/click_elements_steps.rb +24 -0
  40. data/lib/itms_automation/configuration_steps.rb +7 -0
  41. data/lib/itms_automation/input_steps.rb +59 -0
  42. data/lib/itms_automation/javascript_handling_steps.rb +10 -0
  43. data/lib/itms_automation/methods/assertion_methods.rb +333 -0
  44. data/lib/itms_automation/methods/click_elements_methods.rb +23 -0
  45. data/lib/itms_automation/methods/configuration_methods.rb +35 -0
  46. data/lib/itms_automation/methods/error_handling_methods.rb +93 -0
  47. data/lib/itms_automation/methods/input_methods.rb +69 -0
  48. data/lib/itms_automation/methods/javascript_handling_methods.rb +9 -0
  49. data/lib/itms_automation/methods/misc_methods.rb +63 -0
  50. data/lib/itms_automation/methods/navigate_methods.rb +123 -0
  51. data/lib/itms_automation/methods/progress_methods.rb +15 -0
  52. data/lib/itms_automation/methods/required_files.rb +9 -0
  53. data/lib/itms_automation/methods/screenshot_methods.rb +6 -0
  54. data/lib/itms_automation/navigation_steps.rb +79 -0
  55. data/lib/itms_automation/progress_steps.rb +17 -0
  56. data/lib/itms_automation/screenshot_steps.rb +6 -0
  57. data/lib/itms_automation/version.rb +5 -3
  58. metadata +93 -90
  59. data/bin/console +0 -14
  60. data/bin/documentation_generator.rb +0 -119
  61. data/bin/setup +0 -8
  62. data/lib/itms_automation/all_steps.rb +0 -8
  63. data/lib/itms_automation/assertion_helper.rb +0 -29
  64. data/lib/itms_automation/auto_util.rb +0 -702
  65. data/lib/itms_automation/database_steps_helper.rb +0 -125
  66. data/lib/itms_automation/web_steps_helper.rb +0 -844
  67. data/project/Gemfile +0 -3
  68. data/project/Gemfile.lock +0 -92
  69. data/project/README.md +0 -34
  70. data/project/Rakefile +0 -24
  71. data/project/config/chrome_headless_options.yaml +0 -1
  72. data/project/config/chrome_options.yaml +0 -6
  73. data/project/config/firefox_headless_options.yaml +0 -1
  74. data/project/config/firefox_options.yaml +0 -1
  75. data/project/config/ie_options.yaml +0 -1
  76. data/project/config/remote_options.yaml +0 -6
  77. data/project/config/safari_options.yaml +0 -1
  78. data/project/cucumber.yml +0 -4
  79. data/project/features/TestSuite/WebGUI.feature +0 -5
  80. data/project/features/step_definitions/lib_steps/steps_definition.rb +0 -46
  81. data/project/features/step_definitions/repositories/project_object.yml +0 -26
  82. data/project/features/support/env.rb +0 -9
  83. data/project/features/support/hooks.rb +0 -128
@@ -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,844 +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
- debug_log("Stored variable #{var_name}: #{var_value}")
638
- rescue StandardError => e
639
- print_log("failed", start, __method__, var_name, var_value)
640
- raise "Error: #{e.message}"
641
- end
642
- end
643
-
644
- def store_text_element(element, var_name)
645
- start = Time.now
646
- found_element = find_object(element)
647
- if found_element != nil
648
- begin
649
- var_value = "'" + found_element.text() + "'"
650
- set_var(var_name, var_value)
651
- print_log("passed", start, __method__, element, var_name)
652
- debug_log("Stored variable #{var_name}: #{var_value}")
653
- rescue StandardError => e
654
- print_log("failed", start, __method__, element, var_name)
655
- raise "Error: #{e.message}"
656
- end
657
- else
658
- print_log("failed", start, __method__, element, var_name)
659
- raise "Error: Not found object: #{element}"
660
- end
661
- end
662
-
663
- def store_title_current_page(var_name)
664
- start = Time.now
665
- begin
666
- var_value = "'" + page.title + "'"
667
- set_var(var_name, var_value)
668
- print_log("passed", start, __method__, var_name)
669
- debug_log("Stored variable #{var_name}: #{var_value}")
670
- rescue StandardError => e
671
- print_log("failed", start, __method__, var_name)
672
- raise "Error: #{e.message}"
673
- end
674
- end
675
-
676
- def store_element_value(element, var_name)
677
- start = Time.now
678
- found_element = find_object(element)
679
- if found_element != nil
680
- begin
681
- var_value = "'" + found_element.value() + "'"
682
- set_var(var_name, var_value)
683
- print_log("passed", start, __method__, element, var_name)
684
- debug_log("Stored variable #{var_name}: #{var_value}")
685
- rescue StandardError => e
686
- print_log("failed", start, __method__, element, var_name)
687
- raise "Error: #{e.message}"
688
- end
689
- else
690
- print_log("failed", start, __method__, element, var_name)
691
- raise "Error: Not found object: #{element}"
692
- end
693
- end
694
-
695
- def store_element_attribute_value(element, attribute, var_name)
696
- start = Time.now
697
- found_element = find_object(element)
698
- if found_element != nil
699
- begin
700
- var_value = "'" + found_element[attribute] + "'"
701
- set_var(var_name, var_value)
702
- print_log("passed", start, __method__, element, var_name)
703
- debug_log("Stored variable #{var_name}: #{var_value}")
704
- rescue StandardError => e
705
- print_log("failed", start, __method__, element, var_name)
706
- raise "Error: #{e.message}"
707
- end
708
- else
709
- print_log("failed", start, __method__, element, var_name)
710
- raise "Error: Not found object: #{element}"
711
- end
712
- end
713
-
714
- def store_evaluate_script(script, var_name)
715
- start = Time.now
716
- begin
717
- result = page.evaluate_script(<<~JS, script)
718
- (function(scr){
719
- return eval(scr);
720
- })(arguments[0])
721
- JS
722
- var_value = "'" + result.to_s + "'"
723
- set_var(var_name, var_value)
724
- print_log("passed", start, __method__, script, var_name)
725
- debug_log("Stored variable #{var_name}: #{var_value}")
726
- rescue StandardError => e
727
- print_log("failed", start, __method__, script, var_name)
728
- raise "Error: #{e.message}"
729
- end
730
- end
731
-
732
- def check_checkbox_radio(element)
733
- start = Time.now
734
- found_element = find_object(element)
735
- if found_element != nil
736
- begin
737
- page.driver.browser.execute_script("arguments[0].checked = true;", found_element.native)
738
- print_log("passed", start, __method__, element)
739
- rescue StandardError => e
740
- print_log("failed", start, __method__, element)
741
- raise "Error: #{e.message}"
742
- end
743
- else
744
- print_log("failed", start, __method__, element)
745
- raise "Error: Not found object: #{element}"
746
- end
747
- end
748
-
749
- def uncheck_checkbox_radio(element)
750
- start = Time.now
751
- found_element = find_object(element)
752
- if found_element != nil
753
- begin
754
- page.driver.browser.execute_script("arguments[0].checked = false;", found_element.native)
755
- print_log("passed", start, __method__, element)
756
- rescue StandardError => e
757
- print_log("failed", start, __method__, element)
758
- raise "Error: #{e.message}"
759
- end
760
- else
761
- print_log("failed", start, __method__, element)
762
- raise "Error: Not found object: #{element}"
763
- end
764
- end
765
-
766
- def verify_checkbox_radio_checked(element)
767
- start = Time.now
768
- found_element = find_object(element)
769
- if found_element != nil
770
- begin
771
- if found_element.checked?
772
- print_log("passed", start, __method__, element)
773
- else
774
- print_log("failed", start, __method__, element)
775
- end
776
- rescue StandardError => e
777
- print_log("failed", start, __method__, element)
778
- raise "Error: #{e.message}"
779
- end
780
- else
781
- print_log("failed", start, __method__, element)
782
- raise "Error: Not found object: #{element}"
783
- end
784
- end
785
-
786
- def verify_checkbox_radio_not_checked(element)
787
- start = Time.now
788
- found_element = find_object(element)
789
- if found_element != nil
790
- begin
791
- if found_element.checked?
792
- print_log("failed", start, __method__, element)
793
- else
794
- print_log("passed", start, __method__, element)
795
- end
796
- rescue StandardError => e
797
- print_log("failed", start, __method__, element)
798
- raise "Error: #{e.message}"
799
- end
800
- else
801
- print_log("failed", start, __method__, element)
802
- raise "Error: Not found object: #{element}"
803
- end
804
- end
805
-
806
- def verify_input_editable(element)
807
- start = Time.now
808
- found_element = find_object(element)
809
- if found_element != nil
810
- begin
811
- if found_element.disabled?
812
- print_log("passed", start, __method__, element)
813
- else
814
- print_log("failed", start, __method__, element)
815
- end
816
- rescue StandardError => e
817
- print_log("failed", start, __method__, element)
818
- raise "Error: #{e.message}"
819
- end
820
- else
821
- print_log("failed", start, __method__, element)
822
- raise "Error: Not found object: #{element}"
823
- end
824
- end
825
-
826
- def verify_input_not_editable(element)
827
- start = Time.now
828
- found_element = find_object(element)
829
- if found_element != nil
830
- begin
831
- if found_element.disabled?
832
- print_log("failed", start, __method__, element)
833
- else
834
- print_log("passed", start, __method__, element)
835
- end
836
- rescue StandardError => e
837
- print_log("failed", start, __method__, element)
838
- raise "Error: #{e.message}"
839
- end
840
- else
841
- print_log("failed", start, __method__, element)
842
- raise "Error: Not found object: #{element}"
843
- end
844
- end