itms_automation 2.3 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/generate.rb +3 -37
- data/bin/helper.rb +23 -10
- data/bin/itms_automation +18 -23
- data/doc/installation.md +16 -0
- data/doc/itms-automation-API.md +103 -0
- data/doc/itms-automation-help.md +18 -0
- data/example/android/android_app/android_app_calculator.zip +0 -0
- data/example/android/android_app/android_app_calculator/AndroidCalculator.apk +0 -0
- data/example/android/android_app/android_app_calculator/features/calculator.feature +36 -0
- data/example/android/android_app/android_app_calculator/features/my_first.feature +13 -0
- data/example/android/android_app/android_app_calculator/features/screenshots/test.png +0 -0
- data/example/android/android_app/android_app_calculator/features/step_definitions/custom_steps.rb +5 -0
- data/example/android/android_app/android_app_calculator/features/support/env.rb +52 -0
- data/example/android/android_app/android_app_calculator/features/support/hooks.rb +26 -0
- data/example/android/android_web/android_web_gmail_login.zip +0 -0
- data/example/android/android_web/android_web_gmail_login/features/gmail_login.feature +12 -0
- data/example/android/android_web/android_web_gmail_login/features/my_first.feature +1 -0
- data/example/android/android_web/android_web_gmail_login/features/screenshots/test.png +0 -0
- data/example/android/android_web/android_web_gmail_login/features/step_definitions/custom_steps.rb +5 -0
- data/example/android/android_web/android_web_gmail_login/features/support/env.rb +51 -0
- data/example/android/android_web/android_web_gmail_login/features/support/hooks.rb +27 -0
- data/example/desktop web/desktop_web_gmail_login.zip +0 -0
- data/example/desktop web/desktop_web_gmail_login/features/gmail_login.feature +9 -0
- data/example/desktop web/desktop_web_gmail_login/features/gmail_multi_login.feature +21 -0
- data/example/desktop web/desktop_web_gmail_login/features/my_first.feature +1 -0
- data/example/desktop web/desktop_web_gmail_login/features/screenshots/test.png +0 -0
- data/example/desktop web/desktop_web_gmail_login/features/step_definitions/custom_steps.rb +5 -0
- data/example/desktop web/desktop_web_gmail_login/features/support/env.rb +106 -0
- data/example/desktop web/desktop_web_gmail_login/features/support/hooks.rb +38 -0
- data/features-skeleton/my_first.feature +5 -0
- data/features-skeleton/screenshots/test.png +0 -0
- data/features-skeleton/step_definitions/custom_steps.rb +5 -0
- data/features-skeleton/step_definitions/repositories/project_object.yml +1 -0
- data/features-skeleton/support/env.rb +108 -0
- data/features-skeleton/support/hooks.rb +38 -0
- data/lib/itms_automation.rb +1 -3
- data/lib/itms_automation/assertion_steps.rb +68 -0
- data/lib/itms_automation/click_elements_steps.rb +24 -0
- data/lib/itms_automation/configuration_steps.rb +7 -0
- data/lib/itms_automation/input_steps.rb +59 -0
- data/lib/itms_automation/javascript_handling_steps.rb +10 -0
- data/lib/itms_automation/methods/assertion_methods.rb +333 -0
- data/lib/itms_automation/methods/click_elements_methods.rb +23 -0
- data/lib/itms_automation/methods/configuration_methods.rb +35 -0
- data/lib/itms_automation/methods/error_handling_methods.rb +93 -0
- data/lib/itms_automation/methods/input_methods.rb +69 -0
- data/lib/itms_automation/methods/javascript_handling_methods.rb +9 -0
- data/lib/itms_automation/methods/misc_methods.rb +63 -0
- data/lib/itms_automation/methods/navigate_methods.rb +123 -0
- data/lib/itms_automation/methods/progress_methods.rb +15 -0
- data/lib/itms_automation/methods/required_files.rb +9 -0
- data/lib/itms_automation/methods/screenshot_methods.rb +6 -0
- data/lib/itms_automation/navigation_steps.rb +79 -0
- data/lib/itms_automation/progress_steps.rb +17 -0
- data/lib/itms_automation/screenshot_steps.rb +6 -0
- data/lib/itms_automation/version.rb +5 -3
- metadata +93 -90
- data/bin/console +0 -14
- data/bin/documentation_generator.rb +0 -119
- data/bin/setup +0 -8
- data/lib/itms_automation/all_steps.rb +0 -8
- data/lib/itms_automation/assertion_helper.rb +0 -29
- data/lib/itms_automation/auto_util.rb +0 -702
- data/lib/itms_automation/database_steps_helper.rb +0 -125
- data/lib/itms_automation/web_steps_helper.rb +0 -844
- data/project/Gemfile +0 -3
- data/project/Gemfile.lock +0 -92
- data/project/README.md +0 -34
- data/project/Rakefile +0 -24
- data/project/config/chrome_headless_options.yaml +0 -1
- data/project/config/chrome_options.yaml +0 -6
- data/project/config/firefox_headless_options.yaml +0 -1
- data/project/config/firefox_options.yaml +0 -1
- data/project/config/ie_options.yaml +0 -1
- data/project/config/remote_options.yaml +0 -6
- data/project/config/safari_options.yaml +0 -1
- data/project/cucumber.yml +0 -4
- data/project/features/TestSuite/WebGUI.feature +0 -5
- data/project/features/step_definitions/lib_steps/steps_definition.rb +0 -46
- data/project/features/step_definitions/repositories/project_object.yml +0 -26
- data/project/features/support/env.rb +0 -9
- data/project/features/support/hooks.rb +0 -128
data/bin/setup
DELETED
@@ -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,702 +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 debug_log str
|
171
|
-
p str if $print_log == "true"
|
172
|
-
end
|
173
|
-
|
174
|
-
def check_valid_option_by?(option_by)
|
175
|
-
%w(text value).include? option_by
|
176
|
-
end
|
177
|
-
|
178
|
-
def validate_option_by(option_by)
|
179
|
-
raise "Please select valid option, invalid option - #{option_by}" unless check_valid_option_by? option_by
|
180
|
-
end
|
181
|
-
|
182
|
-
def check_valid_keys?(key)
|
183
|
-
%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
|
184
|
-
end
|
185
|
-
|
186
|
-
def validate_supported_keys(key)
|
187
|
-
raise "Please select valid keys, invalid key - #{key}" unless check_valid_option_by? key
|
188
|
-
end
|
189
|
-
|
190
|
-
def find_object string_object
|
191
|
-
startTime = Time.new.to_i
|
192
|
-
string_object = string_object.gsub(/"/, "'")
|
193
|
-
locator_matching = /(.*?)(\{.*?\})/.match(string_object)
|
194
|
-
dyn_pros = {}
|
195
|
-
if locator_matching != nil
|
196
|
-
string_object = locator_matching[1]
|
197
|
-
eval(locator_matching[2].gsub(/['][\s,\t]*?:[\s,\t]*?[']?/, "'=>'")).each { |k, v|
|
198
|
-
dyn_pros[k.to_s.upcase] = v
|
199
|
-
}
|
200
|
-
end
|
201
|
-
hash_object = $OBJECT[string_object]
|
202
|
-
if hash_object == nil
|
203
|
-
raise "❌ find_object error: >>> Object: #{string_object} is not found in Object Repository."
|
204
|
-
end
|
205
|
-
upcase_attrb = {}
|
206
|
-
if hash_object != nil
|
207
|
-
hash_object.each {|k,v|
|
208
|
-
k = k.to_s.upcase
|
209
|
-
if k =~ /ph_/i
|
210
|
-
if dyn_pros[k] != nil
|
211
|
-
if v =~ /<ph_value>/i
|
212
|
-
upcase_attrb[k[3..k.size-1]] = v.gsub(/<ph_value>/i, dyn_pros[k])
|
213
|
-
else
|
214
|
-
upcase_attrb[k[3..k.size-1]] = dyn_pros[k]
|
215
|
-
end
|
216
|
-
dyn_pros.delete(k)
|
217
|
-
end
|
218
|
-
else
|
219
|
-
upcase_attrb[k.to_s.upcase] = v
|
220
|
-
end
|
221
|
-
}
|
222
|
-
end
|
223
|
-
ph_attrs = {}
|
224
|
-
dyn_pros.each{|k,v|
|
225
|
-
if k =~ /ph_/i
|
226
|
-
ph_attrs[k] = v
|
227
|
-
else
|
228
|
-
upcase_attrb[k.to_s.upcase] = v
|
229
|
-
end
|
230
|
-
}
|
231
|
-
if upcase_attrb.size > 0
|
232
|
-
strId = ""
|
233
|
-
strClass = ""
|
234
|
-
strName = ""
|
235
|
-
strTagname = ""
|
236
|
-
strCssSelector = ""
|
237
|
-
strXpathSelector = ""
|
238
|
-
strText = ""
|
239
|
-
strRelated = ""
|
240
|
-
strRelatedType = ""
|
241
|
-
|
242
|
-
index = nil
|
243
|
-
minWidth = -1
|
244
|
-
maxWidth = -1
|
245
|
-
minHeight = -1
|
246
|
-
maxHeight = -1
|
247
|
-
|
248
|
-
ano_pros = {}
|
249
|
-
|
250
|
-
upcase_attrb.each{|key, value|
|
251
|
-
upcase_key = key.to_s.upcase
|
252
|
-
case upcase_key
|
253
|
-
when "XPATH_SELECTOR"
|
254
|
-
strXpathSelector = value
|
255
|
-
when "CSS_SELECTOR"
|
256
|
-
strCssSelector = value
|
257
|
-
when "ID"
|
258
|
-
strId = value
|
259
|
-
when "CLASS"
|
260
|
-
strClass = value
|
261
|
-
when "NAME"
|
262
|
-
strName = value
|
263
|
-
when "TAGNAME"
|
264
|
-
strTagname = value
|
265
|
-
when "TEXT"
|
266
|
-
strText = value
|
267
|
-
when "INDEX"
|
268
|
-
index = value
|
269
|
-
else
|
270
|
-
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"
|
271
|
-
end
|
272
|
-
}
|
273
|
-
continue_run = true;
|
274
|
-
continue_run_count = 1;
|
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
|
-
continue_run_count += 1
|
308
|
-
print "Finding the object..." if continue_run_count == 2
|
309
|
-
print "." if continue_run_count > 2
|
310
|
-
currentTime = Time.new.to_i
|
311
|
-
puts "" if (currentTime - startTime) >= $wait_time
|
312
|
-
else
|
313
|
-
puts ""
|
314
|
-
break
|
315
|
-
end
|
316
|
-
sleep(0.5)
|
317
|
-
end while (currentTime - startTime) < $wait_time
|
318
|
-
|
319
|
-
if foundElements != nil or foundElements.length != 0
|
320
|
-
if index != nil and index.to_i >= 0
|
321
|
-
matched_index = 0;
|
322
|
-
return_element = nil
|
323
|
-
foundElements.each{|cur_element|
|
324
|
-
passCheck = find_object_check_object(cur_element, ref_object, strRelatedType, strId, strClass, strName, strTagname, strText, minWidth, maxWidth, minHeight, maxHeight, ano_pros)
|
325
|
-
if passCheck
|
326
|
-
if matched_index == index.to_i
|
327
|
-
return_element = cur_element
|
328
|
-
break
|
329
|
-
else
|
330
|
-
matched_index = matched_index + 1
|
331
|
-
end
|
332
|
-
end
|
333
|
-
}
|
334
|
-
return return_element
|
335
|
-
else
|
336
|
-
return_element = nil
|
337
|
-
foundElements.each{|cur_element|
|
338
|
-
passCheck = find_object_check_object(cur_element, ref_object, strRelatedType, strId, strClass, strName, strTagname, strText, minWidth, maxWidth, minHeight, maxHeight, ano_pros)
|
339
|
-
if passCheck
|
340
|
-
return_element = cur_element
|
341
|
-
break
|
342
|
-
end
|
343
|
-
}
|
344
|
-
return return_element
|
345
|
-
end # if index != nil and index.to_i >= 0
|
346
|
-
end #if foundElements != nil or foundElements.length != 0
|
347
|
-
end #if continue = true
|
348
|
-
end
|
349
|
-
return nil
|
350
|
-
end
|
351
|
-
|
352
|
-
def generate_xpath_selector(strId, strClass, strName, strTagname)
|
353
|
-
strGenerateXpathSel = ""
|
354
|
-
if strId != nil and strId.length > 0 and (strId =~ /^#/) == nil
|
355
|
-
strGenerateXpathSel = "[@id='#{strId}']"
|
356
|
-
end
|
357
|
-
if strClass != nil and strClass.length > 0 and (strClass =~ /^#/) == nil
|
358
|
-
strGenerateXpathSel = "#{strGenerateXpathSel}[@class='#{strClass}']"
|
359
|
-
end
|
360
|
-
if strName != nil and strName.length > 0 and (strName =~ /^#/) == nil
|
361
|
-
strGenerateXpathSel = "#{strGenerateXpathSel}[@name='#{strName}']"
|
362
|
-
end
|
363
|
-
|
364
|
-
if strGenerateXpathSel.length > 0
|
365
|
-
if strTagname != nil and strTagname.length > 0
|
366
|
-
strGenerateXpathSel = "//#{strTagname}#{strGenerateXpathSel}"
|
367
|
-
else
|
368
|
-
strGenerateXpathSel = "//*#{strGenerateXpathSel}"
|
369
|
-
end
|
370
|
-
end
|
371
|
-
|
372
|
-
return strGenerateXpathSel
|
373
|
-
end
|
374
|
-
|
375
|
-
def check_string_letters_only(strToCheck)
|
376
|
-
if strToCheck != nil and strToCheck.length > 0 and strToCheck =~ /^[a-zA-Z]+$/
|
377
|
-
return true
|
378
|
-
end
|
379
|
-
return false
|
380
|
-
end
|
381
|
-
|
382
|
-
def get_objects_by_Id(strId)
|
383
|
-
foundElements = nil
|
384
|
-
begin
|
385
|
-
foundElements = page.all("*[@id='#{strId}']", visible: false)
|
386
|
-
rescue StandardError => e
|
387
|
-
raise "Error: #{e.message}"
|
388
|
-
end
|
389
|
-
|
390
|
-
return foundElements
|
391
|
-
end
|
392
|
-
|
393
|
-
def get_objects_by_Class(strClass)
|
394
|
-
foundElements = nil
|
395
|
-
begin
|
396
|
-
foundElements = page.all("*[@class='#{strClass}']", visible: false)
|
397
|
-
rescue StandardError => e
|
398
|
-
raise "Error: #{e.message}"
|
399
|
-
end
|
400
|
-
|
401
|
-
return foundElements
|
402
|
-
end
|
403
|
-
|
404
|
-
def get_objects_by_Name(strName)
|
405
|
-
foundElements = nil
|
406
|
-
begin
|
407
|
-
foundElements = page.all("*[@name='#{strName}']", visible: false)
|
408
|
-
rescue StandardError => e
|
409
|
-
raise "Error: #{e.message}"
|
410
|
-
end
|
411
|
-
|
412
|
-
return foundElements
|
413
|
-
end
|
414
|
-
|
415
|
-
def get_objects_by_Tagname(strTagname)
|
416
|
-
foundElements = nil
|
417
|
-
begin
|
418
|
-
foundElements = page.all("#{strTagname}", visible: false)
|
419
|
-
rescue StandardError => e
|
420
|
-
raise "Error: #{e.message}"
|
421
|
-
end
|
422
|
-
|
423
|
-
return foundElements
|
424
|
-
end
|
425
|
-
|
426
|
-
def get_objects_by_css_selector(strCssSelector)
|
427
|
-
foundElements = nil
|
428
|
-
begin
|
429
|
-
foundElements = page.all(:css, strCssSelector, visible: false)
|
430
|
-
rescue StandardError => e
|
431
|
-
raise "Error: #{e.message}"
|
432
|
-
end
|
433
|
-
foundElements
|
434
|
-
end
|
435
|
-
|
436
|
-
def get_objects_by_xpath_selector(strXpathSelector)
|
437
|
-
foundElements = nil
|
438
|
-
begin
|
439
|
-
foundElements = page.all(:xpath, strXpathSelector, visible: false)
|
440
|
-
rescue StandardError => e
|
441
|
-
raise "Error: #{e.message}"
|
442
|
-
end
|
443
|
-
foundElements
|
444
|
-
end
|
445
|
-
|
446
|
-
def find_object_check_object(cur_element, ref_object, ref_object_type, strId, strClass, strName, strTagname, strText, minWidth, maxWidth, minHeight, maxHeight, ano_pros)
|
447
|
-
passCheck = true
|
448
|
-
if cur_element != nil
|
449
|
-
# Check ref_object
|
450
|
-
if (ref_object != nil)
|
451
|
-
if find_object_check_ref_object(ref_object, ref_object_type, cur_element) == false
|
452
|
-
passCheck = false
|
453
|
-
end
|
454
|
-
end
|
455
|
-
|
456
|
-
# Check ID
|
457
|
-
if strId != nil and strId.length > 0
|
458
|
-
if strId =~ /^#/
|
459
|
-
strId = strId[1..-1]
|
460
|
-
end
|
461
|
-
if find_object_check_Id(cur_element, strId) == false
|
462
|
-
passCheck = false
|
463
|
-
end
|
464
|
-
end
|
465
|
-
|
466
|
-
# Check Class
|
467
|
-
if passCheck and strClass != nil and strClass.length > 0
|
468
|
-
if strClass =~ /^#/
|
469
|
-
strClass = strClass[1..-1]
|
470
|
-
end
|
471
|
-
if find_object_check_Class(cur_element, strClass) == false
|
472
|
-
passCheck = false
|
473
|
-
end
|
474
|
-
end
|
475
|
-
|
476
|
-
# Check Name
|
477
|
-
if passCheck and strName != nil and strName.length > 0
|
478
|
-
if strName =~ /^#/
|
479
|
-
strName = strName[1..-1]
|
480
|
-
end
|
481
|
-
if find_object_check_Name(cur_element, strName) == false
|
482
|
-
passCheck = false
|
483
|
-
end
|
484
|
-
end
|
485
|
-
|
486
|
-
# Check Tag name
|
487
|
-
if passCheck and strTagname != nil and strTagname.length > 0
|
488
|
-
if find_object_check_Tagname(cur_element, strTagname) == false
|
489
|
-
passCheck = false
|
490
|
-
end
|
491
|
-
end
|
492
|
-
|
493
|
-
# Check Text
|
494
|
-
if passCheck and strText != nil and strText.length > 0
|
495
|
-
if (strText =~ /^#/)
|
496
|
-
strText = strText[1..-1]
|
497
|
-
end
|
498
|
-
|
499
|
-
if find_object_check_Text(cur_element, strText) == false
|
500
|
-
passCheck = false
|
501
|
-
end
|
502
|
-
end
|
503
|
-
|
504
|
-
# Check minWidth
|
505
|
-
if passCheck and minWidth > 0
|
506
|
-
if !find_object_check_minWidth(cur_element, minWidth)
|
507
|
-
passCheck = false
|
508
|
-
end
|
509
|
-
end
|
510
|
-
|
511
|
-
# Check maxWidth
|
512
|
-
if passCheck and maxWidth > 0
|
513
|
-
if !find_object_check_maxWidth(cur_element, maxWidth)
|
514
|
-
passCheck = false
|
515
|
-
end
|
516
|
-
end
|
517
|
-
|
518
|
-
# Check minHeight
|
519
|
-
if passCheck and minHeight > 0
|
520
|
-
if !find_object_check_minHeight(cur_element, minHeight)
|
521
|
-
passCheck = false
|
522
|
-
end
|
523
|
-
end
|
524
|
-
|
525
|
-
# Check maxHeight
|
526
|
-
if passCheck and maxHeight > 0
|
527
|
-
if !find_object_check_maxHeight(cur_element, maxHeight)
|
528
|
-
passCheck = false
|
529
|
-
end
|
530
|
-
end
|
531
|
-
|
532
|
-
# Check another properties
|
533
|
-
if passCheck and ano_pros.length > 0
|
534
|
-
ano_pros.each{|property, value|
|
535
|
-
if value =~ /^#/
|
536
|
-
value = value[1..-1]
|
537
|
-
end
|
538
|
-
if !find_object_check_property(cur_element, property, value)
|
539
|
-
passCheck = false
|
540
|
-
break
|
541
|
-
end
|
542
|
-
}
|
543
|
-
end
|
544
|
-
|
545
|
-
return passCheck
|
546
|
-
end
|
547
|
-
|
548
|
-
return false
|
549
|
-
end
|
550
|
-
|
551
|
-
def find_object_check_Id(element, strId)
|
552
|
-
actual_Id = element[:id]
|
553
|
-
if actual_Id != nil and actual_Id.length > 0
|
554
|
-
actual_Id = actual_Id.strip
|
555
|
-
if reg_compare(actual_Id, strId)
|
556
|
-
return true
|
557
|
-
end
|
558
|
-
end
|
559
|
-
|
560
|
-
return false
|
561
|
-
end
|
562
|
-
|
563
|
-
def find_object_check_Class(element, strClass)
|
564
|
-
actual_Class = element[:class]
|
565
|
-
if actual_Class != nil and actual_Class.length > 0
|
566
|
-
actual_Class = actual_Class.strip
|
567
|
-
if reg_compare(actual_Class, strClass)
|
568
|
-
return true
|
569
|
-
end
|
570
|
-
end
|
571
|
-
|
572
|
-
return false
|
573
|
-
end
|
574
|
-
|
575
|
-
def find_object_check_Name(element, strName)
|
576
|
-
actual_Name = element[:name]
|
577
|
-
if actual_Name != nil and actual_Name.length > 0
|
578
|
-
actual_Name = actual_Name.strip
|
579
|
-
if reg_compare(actual_Name, strName)
|
580
|
-
return true
|
581
|
-
end
|
582
|
-
end
|
583
|
-
|
584
|
-
return false
|
585
|
-
end
|
586
|
-
|
587
|
-
def find_object_check_Tagname(element, strTagname)
|
588
|
-
actual_Tagname = element.tag_name()
|
589
|
-
if actual_Tagname != nil and actual_Tagname.length > 0
|
590
|
-
actual_Tagname = actual_Tagname.strip
|
591
|
-
if reg_compare(actual_Tagname, strTagname)
|
592
|
-
return true
|
593
|
-
end
|
594
|
-
end
|
595
|
-
|
596
|
-
return false
|
597
|
-
end
|
598
|
-
|
599
|
-
def find_object_check_Xpath(element, strXpath)
|
600
|
-
|
601
|
-
end
|
602
|
-
|
603
|
-
def find_object_check_Text(element, strText)
|
604
|
-
actual_Text = element.text()
|
605
|
-
if actual_Text != nil and actual_Text.length > 0
|
606
|
-
actual_Text = actual_Text.strip
|
607
|
-
if reg_compare(actual_Text, strText)
|
608
|
-
return true
|
609
|
-
end
|
610
|
-
end
|
611
|
-
|
612
|
-
return false
|
613
|
-
end
|
614
|
-
|
615
|
-
def find_object_check_minWidth(element, minWidth)
|
616
|
-
width = element[:width]
|
617
|
-
if (width >= minWidth)
|
618
|
-
return true
|
619
|
-
end
|
620
|
-
|
621
|
-
return false
|
622
|
-
end
|
623
|
-
|
624
|
-
def find_object_check_maxWidth(element, maxWidth)
|
625
|
-
width = element[:width]
|
626
|
-
if (width <= maxWidth)
|
627
|
-
return true
|
628
|
-
end
|
629
|
-
|
630
|
-
return false
|
631
|
-
end
|
632
|
-
|
633
|
-
def find_object_check_minHeight(element, minHeight)
|
634
|
-
height = element[:height]
|
635
|
-
if (height <= minHeight)
|
636
|
-
return true
|
637
|
-
end
|
638
|
-
|
639
|
-
return false
|
640
|
-
end
|
641
|
-
|
642
|
-
def find_object_check_maxHeight(element, maxHeight)
|
643
|
-
height = element[:height]
|
644
|
-
if (height <= maxHeight)
|
645
|
-
return true
|
646
|
-
end
|
647
|
-
|
648
|
-
return false
|
649
|
-
end
|
650
|
-
|
651
|
-
def find_object_check_ref_object(ref_object, ref_type, target_element)
|
652
|
-
begin
|
653
|
-
ref = ref_object.native
|
654
|
-
target = target_element.native
|
655
|
-
if(ref_type == "up" or ref_type == "down")
|
656
|
-
ref_x1 = ref.location.x - 10
|
657
|
-
ref_x2 = ref.location.x + ref.size.width + 10
|
658
|
-
target_x1 = target.location.x
|
659
|
-
target_x2 = target_x1 + target.size.width
|
660
|
-
elsif(ref_type == "left" or ref_type == "right")
|
661
|
-
ref_y1 = ref.location.y - 10
|
662
|
-
ref_y2 = ref.location.y + ref_object.native.size.height + 10
|
663
|
-
target_y1 = target.location.y
|
664
|
-
target_y2 = target_y1 + target.size.height
|
665
|
-
elsif(ref_type == "child" or ref_type == "parent")
|
666
|
-
ref_W = ref.location.x + ref.size.width
|
667
|
-
ref_H = ref.location.y + ref.size.height
|
668
|
-
target_W = target.location.x + target.size.width
|
669
|
-
target_H = target.location.y + target.size.height
|
670
|
-
end
|
671
|
-
|
672
|
-
if(ref_type == "up" and
|
673
|
-
target_x1 > ref_x1 and target_x2 < ref_x2 and # has same column or X Position
|
674
|
-
target.location.y < ref.location.y) # at row or Y position, target is upper
|
675
|
-
return true
|
676
|
-
elsif(ref_type == "down" and
|
677
|
-
target_x1 > ref_x1 and target_x2 < ref_x2 and # has same column or X Position
|
678
|
-
target.location.y > ref.location.y) # at row or Y position, target is at down
|
679
|
-
return true
|
680
|
-
elsif(ref_type == "left" and
|
681
|
-
target.location.x < ref.location.x and # at column or X Position, target is at left
|
682
|
-
target_y1 > ref_y1 and target_y2 < ref_y2) # at row or Y position, target is same as ref object
|
683
|
-
return true
|
684
|
-
elsif(ref_type == "right" and
|
685
|
-
target.location.x > ref.location.x and # at column or X Position, target is at right
|
686
|
-
target_y1 > ref_y1 and target_y2 < ref_y2) # at row or Y position, target is same as ref object
|
687
|
-
return true
|
688
|
-
elsif(ref_type == "child" and
|
689
|
-
(target_W < ref_W) and (target_H < ref_H) and
|
690
|
-
(target.location.x > ref.location.x) and (target.location.y > ref.location.y))
|
691
|
-
return true
|
692
|
-
elsif(ref_type == "parent" and
|
693
|
-
(target_W > ref_W) and (target_H > ref_H) and
|
694
|
-
(target.location.x < ref.location.x) and (target.location.y < ref.location.y))
|
695
|
-
return true
|
696
|
-
end
|
697
|
-
rescue StandardError => e
|
698
|
-
puts "Error: #{e.message}"
|
699
|
-
end
|
700
|
-
|
701
|
-
return false;
|
702
|
-
end
|