itms_automation 2.2 → 2.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) 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 +106 -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 +78 -94
  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 -699
  65. data/lib/itms_automation/database_steps_helper.rb +0 -125
  66. data/lib/itms_automation/web_steps_helper.rb +0 -838
  67. data/project/Gemfile +0 -3
  68. data/project/README.md +0 -34
  69. data/project/Rakefile +0 -24
  70. data/project/config/chrome_headless_options.yaml +0 -1
  71. data/project/config/chrome_options.yaml +0 -6
  72. data/project/config/firefox_headless_options.yaml +0 -1
  73. data/project/config/firefox_options.yaml +0 -1
  74. data/project/config/ie_options.yaml +0 -1
  75. data/project/config/remote_options.yaml +0 -6
  76. data/project/config/safari_options.yaml +0 -1
  77. data/project/cucumber.yml +0 -4
  78. data/project/features/TestSuite/WebGUI.feature +0 -4
  79. data/project/features/step_definitions/lib_steps/steps_definition.rb +0 -3
  80. data/project/features/step_definitions/repositories/project_object.yml +0 -2
  81. data/project/features/support/env.rb +0 -10
  82. data/project/features/support/hooks.rb +0 -128
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,8 +0,0 @@
1
- # coding: UTF-8
2
-
3
- Dir[File.join(File.dirname(__FILE__), '*_steps.rb')].each do |f|
4
- name = File.basename(f, '.rb')
5
- unless name == 'all_steps'
6
- require "itms_automation/#{name}"
7
- end
8
- end
@@ -1,29 +0,0 @@
1
- def do_assertion_json expected_obj, actual_obj
2
- if expected_obj.kind_of? Array
3
- is_contain = true
4
- expected_obj.each_with_index do |expected, index|
5
- is_contain = do_assertion_json(expected, actual_obj)
6
- @expected.shift if is_contain == true
7
- return is_contain if is_contain == false || index == expected_obj.length - 1
8
- end
9
- elsif expected_obj.kind_of? Hash
10
- is_contain = true
11
- expected_obj_keys = expected_obj.keys
12
- expected_obj_keys.each_with_index do |key, index|
13
- if actual_obj[key].nil?
14
- raise "[%s] expected [%s] but actual value was nil." % [key, expected_obj[key].to_s]
15
- else
16
- is_contain = expected_obj[key] == actual_obj[key]
17
- return is_contain if is_contain == false || index == expected_obj_keys.length - 1
18
- end
19
- end
20
- elsif [Integer, String, Float].include? expected_obj.class
21
- return assert_string_equal(expected_obj, actual_obj)
22
- else
23
- raise "Verify sql result error: Not support expected type #{expected_obj.class} yet"
24
- end
25
- end
26
-
27
- def assert_string_equal expected, actual
28
- actual.to_s == expected.to_s
29
- end
@@ -1,699 +0,0 @@
1
- #-----------------------------------------------------
2
- # support define and bind variable dynamically
3
- #-----------------------------------------------------
4
- $dyn_vars = nil
5
-
6
- # set value to a variable
7
- def set_var(var_name, var_value)
8
- if $dyn_vars == nil
9
- $dyn_vars = binding
10
- end
11
-
12
- strEval = var_name + "=" + var_value
13
- eval strEval, $dyn_vars
14
- end
15
-
16
- def get_var(var_name)
17
- $dyn_vars.local_variable_get(var_name)
18
- end
19
-
20
- def check_dynamic_value(value)
21
- if !value.is_a? Fixnum
22
- if value.include? "params="
23
- resolve_params value
24
- else
25
- bind_with_dyn_vars value
26
- end
27
- else
28
- value
29
- end
30
- end
31
-
32
- # bind string with $dyn_vars context
33
- def bind_with_dyn_vars(str)
34
- if $dyn_vars == nil
35
- $dyn_vars = binding
36
- end
37
-
38
- strEval = '"' + str + '"'
39
- return eval strEval, $dyn_vars
40
- end
41
-
42
- # evaluate operation/statement with $dyn_vars context
43
- def eval_with_dyn_vars(operation)
44
- if $dyn_vars == nil
45
- $dyn_vars = binding
46
- end
47
-
48
- eval operation, $dyn_vars
49
- end
50
-
51
- def bind_with_dyn_json_vars(json, bind_json)
52
- if json.kind_of? Hash
53
- json.each_pair do |k, v|
54
- if v.kind_of? String
55
- bind_json[bind_with_dyn_vars(k)] = bind_with_dyn_json_vars(v, bind_json)
56
- elsif v.kind_of? Hash
57
- temp = Hash.new
58
- v.each_pair do |k1, v1|
59
- temp[bind_with_dyn_vars(k1)] = bind_with_dyn_json_vars(v1, temp)
60
- end
61
- bind_json[bind_with_dyn_vars(k)] = temp
62
- elsif v.kind_of? Array
63
- temp1 = Array.new
64
- v.each { |item|
65
- temp2 = Hash.new
66
- bind_with_dyn_json_vars(item, temp2)
67
- temp1 << temp2
68
- }
69
- bind_json[bind_with_dyn_vars(k)] = temp1
70
- end
71
- end
72
- elsif json.kind_of? Array
73
- temp1 = Array.new
74
- json.each { |item|
75
- temp2 = Hash.new
76
- bind_with_dyn_json_vars(item, temp2)
77
- temp1 << temp2
78
- }
79
- return temp1
80
- else
81
- return bind_with_dyn_vars(json)
82
- end
83
- end
84
-
85
- def var_collect(string_var)
86
- if string_var =~ /^.*{year}.*$/
87
- string_var = replace_year(string_var)
88
- end
89
-
90
- if string_var =~ /^.*{month}.*$/
91
- string_var = replace_month(string_var)
92
- end
93
-
94
- if string_var =~ /^.*{day}.*$/
95
- string_var = replace_day(string_var)
96
- end
97
-
98
- if string_var =~ /^.*{store_value}.*$/
99
- string_var = $context_value
100
- end
101
-
102
- return string_var
103
- end
104
-
105
- def replace_year(str)
106
- t = Time.now()
107
- return str.gsub("{year}", t.year.to_s)
108
- end
109
-
110
- def replace_month(str)
111
- t = Time.now()
112
- _month = t.month
113
- if _month < 10
114
- return str.gsub("{month}", "0#{_month.to_s}")
115
- else
116
- return str.gsub("{month}", "#{_month.to_s}")
117
- end
118
- return str
119
- end
120
-
121
- def replace_day(str)
122
- t = Time.now()
123
- _day = t.day
124
- if _day < 10
125
- return str.gsub("{day}", "0#{_day.to_s}")
126
- else
127
- return str.gsub("{day}", "#{_day.to_s}")
128
- end
129
- return str
130
- end
131
-
132
- def print_variable(variable)
133
- puts "VALUE OF #{variable}: #{eval_with_dyn_vars(variable)}"
134
- end
135
-
136
- def duration(start)
137
- current = Time.now.to_f
138
- convert_time = Time.at(current - start.to_f).utc.strftime('%Mm%s.%Ls')
139
- return convert_time
140
- end
141
-
142
- def print_log(status, start, method, *args)
143
- icon = status === "passed" ? "✅" : "❌"
144
- str = ""
145
- args = *args
146
- args_length = args.length - 1
147
- args.each_with_index do |a, i|
148
- if i < args_length
149
- str += "\"#{a}\", "
150
- else
151
- str += "\"#{a}\""
152
- end
153
- end
154
-
155
- puts "#{icon} Step: #{method}(#{str}) (#{duration(start)})"
156
- end
157
-
158
- def get_object_value(str_obj)
159
- string_object = str_obj.gsub(/"/, "'")
160
- hash_object = $OBJECT[string_object]
161
- if hash_object == nil
162
- raise "❌ Error: #{str_obj} NAME MAYBE NOT FOUND!!!"
163
- end
164
- if hash_object.keys[0].to_s.upcase != "CSS_SELECTOR"
165
- raise "❌ Error: #{str_obj} should be formatted as Css Selector."
166
- end
167
- hash_object[hash_object.keys[0]]
168
- end
169
-
170
- def put_log str
171
- start = Time.now
172
- p str if $print_log == true
173
- end
174
-
175
- def check_valid_option_by?(option_by)
176
- %w(text value).include? option_by
177
- end
178
-
179
- def validate_option_by(option_by)
180
- raise "Please select valid option, invalid option - #{option_by}" unless check_valid_option_by? option_by
181
- end
182
-
183
- def check_valid_keys?(key)
184
- %w(:cancel :help :backspace :tab :clear :return :enter :shift :control :alt :pause :escape :space :page_up :page_down :end :home :left :up :right :down :insert :delete :semicolon :equals).include? key
185
- end
186
-
187
- def validate_supported_keys(key)
188
- raise "Please select valid keys, invalid key - #{key}" unless check_valid_option_by? key
189
- end
190
-
191
- def find_object string_object
192
- startTime = Time.new.to_i
193
- string_object = string_object.gsub(/"/, "'")
194
- locator_matching = /(.*?)(\{.*?\})/.match(string_object)
195
- dyn_pros = {}
196
- if locator_matching != nil
197
- string_object = locator_matching[1]
198
- eval(locator_matching[2].gsub(/['][\s,\t]*?:[\s,\t]*?[']?/, "'=>'")).each { |k, v|
199
- dyn_pros[k.to_s.upcase] = v
200
- }
201
- end
202
- hash_object = $OBJECT[string_object]
203
- if hash_object == nil
204
- raise "❌ find_object error: >>> Object: #{string_object} is not found in Object Repository."
205
- end
206
- upcase_attrb = {}
207
- if hash_object != nil
208
- hash_object.each {|k,v|
209
- k = k.to_s.upcase
210
- if k =~ /ph_/i
211
- if dyn_pros[k] != nil
212
- if v =~ /<ph_value>/i
213
- upcase_attrb[k[3..k.size-1]] = v.gsub(/<ph_value>/i, dyn_pros[k])
214
- else
215
- upcase_attrb[k[3..k.size-1]] = dyn_pros[k]
216
- end
217
- dyn_pros.delete(k)
218
- end
219
- else
220
- upcase_attrb[k.to_s.upcase] = v
221
- end
222
- }
223
- end
224
- ph_attrs = {}
225
- dyn_pros.each{|k,v|
226
- if k =~ /ph_/i
227
- ph_attrs[k] = v
228
- else
229
- upcase_attrb[k.to_s.upcase] = v
230
- end
231
- }
232
- if upcase_attrb.size > 0
233
- strId = ""
234
- strClass = ""
235
- strName = ""
236
- strTagname = ""
237
- strCssSelector = ""
238
- strXpathSelector = ""
239
- strText = ""
240
- strRelated = ""
241
- strRelatedType = ""
242
-
243
- index = nil
244
- minWidth = -1
245
- maxWidth = -1
246
- minHeight = -1
247
- maxHeight = -1
248
-
249
- ano_pros = {}
250
-
251
- upcase_attrb.each{|key, value|
252
- upcase_key = key.to_s.upcase
253
- case upcase_key
254
- when "XPATH_SELECTOR"
255
- strXpathSelector = value
256
- when "CSS_SELECTOR"
257
- strCssSelector = value
258
- when "ID"
259
- strId = value
260
- when "CLASS"
261
- strClass = value
262
- when "NAME"
263
- strName = value
264
- when "TAGNAME"
265
- strTagname = value
266
- when "TEXT"
267
- strText = value
268
- when "INDEX"
269
- index = value
270
- else
271
- raise "❌ find_object error: >>> Wrong format type: #{key.to_s} of object: #{string_object}. Available supported format are: XPATH_SELECTOR | CSS_SELECTOR | ID | NAME | CLASS | TEXT | TAGNAME | INDEX"
272
- end
273
- }
274
- continue_run = true;
275
- ref_object = nil;
276
-
277
- if strRelated != nil and strRelated.length > 0
278
- ref_object = find_object(strRelated)
279
- if (ref_object == nil)
280
- continue_run = false
281
- end
282
- end
283
-
284
- if continue_run == true
285
- begin
286
- if strCssSelector != nil and strCssSelector.length > 0
287
- foundElements = get_objects_by_css_selector(strCssSelector)
288
- elsif strXpathSelector != nil and strXpathSelector.length > 0
289
- foundElements = get_objects_by_xpath_selector(strXpathSelector)
290
- else
291
- strGenerateXpathSel = generate_xpath_selector(strId, strClass, strName, strTagname)
292
- if strGenerateXpathSel.length > 0
293
- foundElements = get_objects_by_xpath_selector(strGenerateXpathSel)
294
- else
295
- if (check_string_letters_only(strId))
296
- foundElements = get_objects_by_Id(strId)
297
- elsif (check_string_letters_only(strName))
298
- foundElements = get_objects_by_Name(strName)
299
- elsif (check_string_letters_only(strClass))
300
- foundElements = get_objects_by_Class(strClass)
301
- elsif (check_string_letters_only(strTagname))
302
- foundElements = get_objects_by_Tagname(strTagname)
303
- end
304
- end
305
- end
306
- if foundElements == nil or foundElements.length == 0
307
- currentTime = Time.new.to_i
308
- else
309
- break
310
- end
311
- test = currentTime - startTime
312
- puts "\n Finding the object #{string_object}... TIME-OUT:: #{test} < #{$wait_time}"
313
- sleep(0.5)
314
- end while (currentTime - startTime) < $wait_time
315
-
316
- if foundElements != nil or foundElements.length != 0
317
- if index != nil and index.to_i >= 0
318
- matched_index = 0;
319
- return_element = nil
320
- foundElements.each{|cur_element|
321
- passCheck = find_object_check_object(cur_element, ref_object, strRelatedType, strId, strClass, strName, strTagname, strText, minWidth, maxWidth, minHeight, maxHeight, ano_pros)
322
- if passCheck
323
- if matched_index == index.to_i
324
- return_element = cur_element
325
- break
326
- else
327
- matched_index = matched_index + 1
328
- end
329
- end
330
- }
331
- return return_element
332
- else
333
- return_element = nil
334
- foundElements.each{|cur_element|
335
- passCheck = find_object_check_object(cur_element, ref_object, strRelatedType, strId, strClass, strName, strTagname, strText, minWidth, maxWidth, minHeight, maxHeight, ano_pros)
336
- if passCheck
337
- return_element = cur_element
338
- break
339
- end
340
- }
341
- return return_element
342
- end # if index != nil and index.to_i >= 0
343
- end #if foundElements != nil or foundElements.length != 0
344
- end #if continue = true
345
- end
346
- return nil
347
- end
348
-
349
- def generate_xpath_selector(strId, strClass, strName, strTagname)
350
- strGenerateXpathSel = ""
351
- if strId != nil and strId.length > 0 and (strId =~ /^#/) == nil
352
- strGenerateXpathSel = "[@id='#{strId}']"
353
- end
354
- if strClass != nil and strClass.length > 0 and (strClass =~ /^#/) == nil
355
- strGenerateXpathSel = "#{strGenerateXpathSel}[@class='#{strClass}']"
356
- end
357
- if strName != nil and strName.length > 0 and (strName =~ /^#/) == nil
358
- strGenerateXpathSel = "#{strGenerateXpathSel}[@name='#{strName}']"
359
- end
360
-
361
- if strGenerateXpathSel.length > 0
362
- if strTagname != nil and strTagname.length > 0
363
- strGenerateXpathSel = "//#{strTagname}#{strGenerateXpathSel}"
364
- else
365
- strGenerateXpathSel = "//*#{strGenerateXpathSel}"
366
- end
367
- end
368
-
369
- return strGenerateXpathSel
370
- end
371
-
372
- def check_string_letters_only(strToCheck)
373
- if strToCheck != nil and strToCheck.length > 0 and strToCheck =~ /^[a-zA-Z]+$/
374
- return true
375
- end
376
- return false
377
- end
378
-
379
- def get_objects_by_Id(strId)
380
- foundElements = nil
381
- begin
382
- foundElements = page.all("*[@id='#{strId}']")
383
- rescue StandardError => e
384
- raise "Error: #{e.message}"
385
- end
386
-
387
- return foundElements
388
- end
389
-
390
- def get_objects_by_Class(strClass)
391
- foundElements = nil
392
- begin
393
- foundElements = page.all("*[@class='#{strClass}']")
394
- rescue StandardError => e
395
- raise "Error: #{e.message}"
396
- end
397
-
398
- return foundElements
399
- end
400
-
401
- def get_objects_by_Name(strName)
402
- foundElements = nil
403
- begin
404
- foundElements = page.all("*[@name='#{strName}']")
405
- rescue StandardError => e
406
- raise "Error: #{e.message}"
407
- end
408
-
409
- return foundElements
410
- end
411
-
412
- def get_objects_by_Tagname(strTagname)
413
- foundElements = nil
414
- begin
415
- foundElements = page.all("#{strTagname}")
416
- rescue StandardError => e
417
- raise "Error: #{e.message}"
418
- end
419
-
420
- return foundElements
421
- end
422
-
423
- def get_objects_by_css_selector(strCssSelector)
424
- foundElements = nil
425
- begin
426
- foundElements = page.all(:css, strCssSelector)
427
- rescue StandardError => e
428
- raise "Error: #{e.message}"
429
- end
430
- foundElements
431
- end
432
-
433
- def get_objects_by_xpath_selector(strXpathSelector)
434
- foundElements = nil
435
- begin
436
- foundElements = page.all(:xpath, strXpathSelector)
437
- rescue StandardError => e
438
- raise "Error: #{e.message}"
439
- end
440
- foundElements
441
- end
442
-
443
- def find_object_check_object(cur_element, ref_object, ref_object_type, strId, strClass, strName, strTagname, strText, minWidth, maxWidth, minHeight, maxHeight, ano_pros)
444
- passCheck = true
445
- if cur_element != nil
446
- # Check ref_object
447
- if (ref_object != nil)
448
- if find_object_check_ref_object(ref_object, ref_object_type, cur_element) == false
449
- passCheck = false
450
- end
451
- end
452
-
453
- # Check ID
454
- if strId != nil and strId.length > 0
455
- if strId =~ /^#/
456
- strId = strId[1..-1]
457
- end
458
- if find_object_check_Id(cur_element, strId) == false
459
- passCheck = false
460
- end
461
- end
462
-
463
- # Check Class
464
- if passCheck and strClass != nil and strClass.length > 0
465
- if strClass =~ /^#/
466
- strClass = strClass[1..-1]
467
- end
468
- if find_object_check_Class(cur_element, strClass) == false
469
- passCheck = false
470
- end
471
- end
472
-
473
- # Check Name
474
- if passCheck and strName != nil and strName.length > 0
475
- if strName =~ /^#/
476
- strName = strName[1..-1]
477
- end
478
- if find_object_check_Name(cur_element, strName) == false
479
- passCheck = false
480
- end
481
- end
482
-
483
- # Check Tag name
484
- if passCheck and strTagname != nil and strTagname.length > 0
485
- if find_object_check_Tagname(cur_element, strTagname) == false
486
- passCheck = false
487
- end
488
- end
489
-
490
- # Check Text
491
- if passCheck and strText != nil and strText.length > 0
492
- if (strText =~ /^#/)
493
- strText = strText[1..-1]
494
- end
495
-
496
- if find_object_check_Text(cur_element, strText) == false
497
- passCheck = false
498
- end
499
- end
500
-
501
- # Check minWidth
502
- if passCheck and minWidth > 0
503
- if !find_object_check_minWidth(cur_element, minWidth)
504
- passCheck = false
505
- end
506
- end
507
-
508
- # Check maxWidth
509
- if passCheck and maxWidth > 0
510
- if !find_object_check_maxWidth(cur_element, maxWidth)
511
- passCheck = false
512
- end
513
- end
514
-
515
- # Check minHeight
516
- if passCheck and minHeight > 0
517
- if !find_object_check_minHeight(cur_element, minHeight)
518
- passCheck = false
519
- end
520
- end
521
-
522
- # Check maxHeight
523
- if passCheck and maxHeight > 0
524
- if !find_object_check_maxHeight(cur_element, maxHeight)
525
- passCheck = false
526
- end
527
- end
528
-
529
- # Check another properties
530
- if passCheck and ano_pros.length > 0
531
- ano_pros.each{|property, value|
532
- if value =~ /^#/
533
- value = value[1..-1]
534
- end
535
- if !find_object_check_property(cur_element, property, value)
536
- passCheck = false
537
- break
538
- end
539
- }
540
- end
541
-
542
- return passCheck
543
- end
544
-
545
- return false
546
- end
547
-
548
- def find_object_check_Id(element, strId)
549
- actual_Id = element[:id]
550
- if actual_Id != nil and actual_Id.length > 0
551
- actual_Id = actual_Id.strip
552
- if reg_compare(actual_Id, strId)
553
- return true
554
- end
555
- end
556
-
557
- return false
558
- end
559
-
560
- def find_object_check_Class(element, strClass)
561
- actual_Class = element[:class]
562
- if actual_Class != nil and actual_Class.length > 0
563
- actual_Class = actual_Class.strip
564
- if reg_compare(actual_Class, strClass)
565
- return true
566
- end
567
- end
568
-
569
- return false
570
- end
571
-
572
- def find_object_check_Name(element, strName)
573
- actual_Name = element[:name]
574
- if actual_Name != nil and actual_Name.length > 0
575
- actual_Name = actual_Name.strip
576
- if reg_compare(actual_Name, strName)
577
- return true
578
- end
579
- end
580
-
581
- return false
582
- end
583
-
584
- def find_object_check_Tagname(element, strTagname)
585
- actual_Tagname = element.tag_name()
586
- if actual_Tagname != nil and actual_Tagname.length > 0
587
- actual_Tagname = actual_Tagname.strip
588
- if reg_compare(actual_Tagname, strTagname)
589
- return true
590
- end
591
- end
592
-
593
- return false
594
- end
595
-
596
- def find_object_check_Xpath(element, strXpath)
597
-
598
- end
599
-
600
- def find_object_check_Text(element, strText)
601
- actual_Text = element.text()
602
- if actual_Text != nil and actual_Text.length > 0
603
- actual_Text = actual_Text.strip
604
- if reg_compare(actual_Text, strText)
605
- return true
606
- end
607
- end
608
-
609
- return false
610
- end
611
-
612
- def find_object_check_minWidth(element, minWidth)
613
- width = element[:width]
614
- if (width >= minWidth)
615
- return true
616
- end
617
-
618
- return false
619
- end
620
-
621
- def find_object_check_maxWidth(element, maxWidth)
622
- width = element[:width]
623
- if (width <= maxWidth)
624
- return true
625
- end
626
-
627
- return false
628
- end
629
-
630
- def find_object_check_minHeight(element, minHeight)
631
- height = element[:height]
632
- if (height <= minHeight)
633
- return true
634
- end
635
-
636
- return false
637
- end
638
-
639
- def find_object_check_maxHeight(element, maxHeight)
640
- height = element[:height]
641
- if (height <= maxHeight)
642
- return true
643
- end
644
-
645
- return false
646
- end
647
-
648
- def find_object_check_ref_object(ref_object, ref_type, target_element)
649
- begin
650
- ref = ref_object.native
651
- target = target_element.native
652
- if(ref_type == "up" or ref_type == "down")
653
- ref_x1 = ref.location.x - 10
654
- ref_x2 = ref.location.x + ref.size.width + 10
655
- target_x1 = target.location.x
656
- target_x2 = target_x1 + target.size.width
657
- elsif(ref_type == "left" or ref_type == "right")
658
- ref_y1 = ref.location.y - 10
659
- ref_y2 = ref.location.y + ref_object.native.size.height + 10
660
- target_y1 = target.location.y
661
- target_y2 = target_y1 + target.size.height
662
- elsif(ref_type == "child" or ref_type == "parent")
663
- ref_W = ref.location.x + ref.size.width
664
- ref_H = ref.location.y + ref.size.height
665
- target_W = target.location.x + target.size.width
666
- target_H = target.location.y + target.size.height
667
- end
668
-
669
- if(ref_type == "up" and
670
- target_x1 > ref_x1 and target_x2 < ref_x2 and # has same column or X Position
671
- target.location.y < ref.location.y) # at row or Y position, target is upper
672
- return true
673
- elsif(ref_type == "down" and
674
- target_x1 > ref_x1 and target_x2 < ref_x2 and # has same column or X Position
675
- target.location.y > ref.location.y) # at row or Y position, target is at down
676
- return true
677
- elsif(ref_type == "left" and
678
- target.location.x < ref.location.x and # at column or X Position, target is at left
679
- target_y1 > ref_y1 and target_y2 < ref_y2) # at row or Y position, target is same as ref object
680
- return true
681
- elsif(ref_type == "right" and
682
- target.location.x > ref.location.x and # at column or X Position, target is at right
683
- target_y1 > ref_y1 and target_y2 < ref_y2) # at row or Y position, target is same as ref object
684
- return true
685
- elsif(ref_type == "child" and
686
- (target_W < ref_W) and (target_H < ref_H) and
687
- (target.location.x > ref.location.x) and (target.location.y > ref.location.y))
688
- return true
689
- elsif(ref_type == "parent" and
690
- (target_W > ref_W) and (target_H > ref_H) and
691
- (target.location.x < ref.location.x) and (target.location.y < ref.location.y))
692
- return true
693
- end
694
- rescue StandardError => e
695
- puts "Error: #{e.message}"
696
- end
697
-
698
- return false;
699
- end