itms_automation 2.4 → 2.6.1

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