Ifd_Automation 2.6 → 2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/bin/generate.rb +21 -3
  3. data/bin/helper.rb +5 -4
  4. data/lib/Ifd_Automation/require_libs.rb +9 -6
  5. data/lib/Ifd_Automation/version.rb +1 -1
  6. data/lib/helper/{assertion_helpers.rb → assertion_helper.rb} +5 -5
  7. data/lib/helper/auto_util.rb +164 -0
  8. data/lib/helper/database_helper.rb +81 -0
  9. data/lib/helper/file_helper.rb +36 -0
  10. data/lib/helper/mail_helper.rb +58 -0
  11. data/lib/helper/rest_helper.rb +91 -0
  12. data/lib/helper/soap_helper.rb +59 -0
  13. data/lib/helper/ssh_helper.rb +39 -0
  14. data/lib/helper/web_steps_helper.rb +447 -0
  15. data/project/Dockerfile +20 -0
  16. data/project/Gemfile.lock +176 -0
  17. data/project/README.md +60 -0
  18. data/project/cucumber.yml +6 -0
  19. data/project/docker-compose.yml +7 -0
  20. data/project/features/TestData/globalData.yml +3 -1
  21. data/project/features/TestSuite/WebGUI.feature +16 -2
  22. data/project/features/step_definitions/IFD_Libraries/REST_steps.rb +34 -0
  23. data/project/features/step_definitions/IFD_Libraries/SOAP_steps.rb +38 -0
  24. data/project/features/step_definitions/IFD_Libraries/database_steps.rb +44 -0
  25. data/{lib/Ifd_Automation/dynamic_store_vavue_steps.rb → project/features/step_definitions/IFD_Libraries/dynamic_store_value_steps.rb} +8 -10
  26. data/project/features/step_definitions/IFD_Libraries/email_steps.rb +36 -0
  27. data/project/features/step_definitions/IFD_Libraries/file_steps.rb +11 -0
  28. data/project/features/step_definitions/IFD_Libraries/ssh_steps.rb +20 -0
  29. data/{lib/Ifd_Automation → project/features/step_definitions/IFD_Libraries}/web_steps.rb +18 -8
  30. data/project/features/step_definitions/lib_steps/actionwords.rb +14 -10
  31. data/project/features/step_definitions/lib_steps/steps.rb +6 -0
  32. data/project/features/step_definitions/repositories/project_object.yml +2 -6
  33. data/project/features/support/env.rb +18 -18
  34. data/project/features/support/hooks.rb +22 -59
  35. metadata +45 -17
  36. data/lib/Ifd_Automation/REST_steps.rb +0 -90
  37. data/lib/Ifd_Automation/SOAP_steps.rb +0 -68
  38. data/lib/Ifd_Automation/database_steps.rb +0 -80
  39. data/lib/Ifd_Automation/email_steps.rb +0 -72
  40. data/lib/Ifd_Automation/file_steps.rb +0 -24
  41. data/lib/Ifd_Automation/ssh_steps.rb +0 -38
  42. data/lib/helper/auto_utils.rb +0 -67
  43. data/lib/helper/connection_helpers.rb +0 -15
  44. data/lib/helper/core.rb +0 -646
  45. data/lib/helper/mail_helpers.rb +0 -17
  46. data/lib/helper/web_steps_helpers.rb +0 -176
  47. data/project/features/step_definitions/lib_steps/test.rb +0 -6
@@ -0,0 +1,91 @@
1
+ require 'httparty'
2
+ class IFD_Rest
3
+ def self.set_headers(data)
4
+ unless data.hashes.empty?
5
+ data = data.hashes[0]
6
+ data = JSON.parse(data) unless data.is_a? Hash
7
+
8
+ data.each_pair do |k, v|
9
+ data[k] = Utils.check_dynamic_value(v)
10
+ end
11
+ @header = data
12
+ end
13
+ p "HEADER: #{@header}"
14
+ end
15
+
16
+ def self.get_rest_result
17
+ if @response.nil?
18
+ p "WARNING***: MISSING STEPS: Please send a REST request to get response first."
19
+ end
20
+ @response
21
+ end
22
+
23
+ def self.store_json_node_result(json_node,string)
24
+ $context_value = JsonPath.new(json_node).on(IFD_Rest.get_rest_result.body).to_a.map(&:to_s)[0]
25
+ Utils.set_var(string, '$context_value')
26
+ end
27
+
28
+ def self.print_rest_code
29
+ puts "REST RESULT code: #{IFD_Rest.get_rest_result.code}"
30
+ end
31
+
32
+ def self.get_rest_body
33
+ puts "REST RESULT body: #{IFD_Rest.get_rest_result.body}"
34
+ end
35
+
36
+ def self.verify_rest_response_code(code)
37
+ IFD_Assertion.assert_string_equal(code, IFD_Rest.get_rest_result.code.to_s)
38
+ end
39
+
40
+ def self.verify_response_body_with_json(json)
41
+ IFD_Assertion.assert_string_equal(json, IFD_Rest.get_rest_result.body.to_s)
42
+ end
43
+
44
+ def self.verify_response_at_json_node(json_node,string)
45
+ result = JsonPath.new(json_node).on(IFD_Rest.get_rest_result.body).to_a.map(&:to_s)
46
+ IFD_Assertion.assert_string_equal(string, result[0])
47
+ end
48
+
49
+ def self.send_request(*args)
50
+ request_type = args.shift.downcase
51
+ url = Utils.check_dynamic_value(args.shift)
52
+ put_log "Request URL: #{url}"
53
+ json_payload = args.shift
54
+ if json_payload
55
+ payload = Hash.new
56
+ JSON.parse(json_payload).each do |k1, v1|
57
+ payload[Utils.check_dynamic_value(k1)] = Utils.check_dynamic_value(v1)
58
+ end
59
+ payload = payload.to_json
60
+ end
61
+ put_log "Data Body from #{request_type} method: #{payload}"
62
+
63
+ if (payload.nil? && request_type == 'get' && @header.nil?)
64
+ @response = Request.get(url)
65
+ elsif (payload.nil? && request_type == 'get')
66
+ @response = Request.get(url, {headers: @header})
67
+ elsif (payload.nil? && request_type == 'delete' && @header.nil?)
68
+ @response = Request.delete(url)
69
+ elsif (payload.nil? && request_type == 'delete')
70
+ @response = Request.delete(url, {headers: @header})
71
+ elsif (payload && request_type == 'get' && @header.nil?)
72
+ @response = Request.get(url, {body: payload})
73
+ elsif (payload && request_type == 'get')
74
+ @response = Request.get(url, {body: payload, headers: @header})
75
+ elsif (payload && request_type == 'post' && @header.nil?)
76
+ @response = Request.post(url, {body: payload})
77
+ elsif (payload && request_type == 'post')
78
+ @response = Request.post(url, {body: payload, headers: @header})
79
+ elsif (payload && request_type == 'put' && @header.nil?)
80
+ @response = Request.put(url, {body: payload})
81
+ elsif (payload && request_type == 'put')
82
+ @response = Request.put(url, {body: payload, headers: @header})
83
+ end
84
+ end
85
+
86
+ end
87
+
88
+ class Request
89
+ include HTTParty
90
+ default_options.update(verify: false)
91
+ end
@@ -0,0 +1,59 @@
1
+ require 'savon'
2
+ require 'jsonpath'
3
+
4
+ class IFD_Soap
5
+ def self.get_soap_operation_list(url)
6
+ request_url = URI.encode Utils.check_dynamic_value url
7
+ @SOAPclient = Savon.client(ssl_verify_mode: :none,
8
+ wsdl: "#{request_url}",
9
+ :open_timeout => 10,
10
+ :read_timeout => 10,
11
+ :log => false)
12
+ p "Operations List: #{@SOAPclient.operations}"
13
+ end
14
+
15
+ def self.call_and_fail_gracefully(client, *args, &block)
16
+ if client.nil?
17
+ raise "ERROR***: MISSING STEPS: Please run step to get operation list from WSDL first."
18
+ else
19
+ client.call(*args, &block)
20
+ end
21
+ rescue Savon::SOAPFault => e
22
+ raise e.message
23
+ end
24
+
25
+ def self.get_soap_response
26
+ soap_response = @response
27
+ if soap_response.nil?
28
+ raise "ERROR***: MISSING STEPS: Please send SOAP request to get the response first."
29
+ else
30
+ soap_response
31
+ end
32
+ soap_response
33
+ end
34
+
35
+ def self.send_soap_with_operation_and_xml(operation,file_name)
36
+ xml = File.read($test_data_dir + file_name)
37
+ @response = IFD_Soap.call_and_fail_gracefully(@SOAPclient, operation.downcase.to_sym, xml: xml )
38
+ end
39
+
40
+ def self.send_soap_with_operation_and_data(operation,data)
41
+ xml = Utils.bind_with_dyn_vars(data)
42
+ @response = IFD_Soap.call_and_fail_gracefully(@SOAPclient, operation.downcase.to_sym, xml: xml )
43
+ end
44
+
45
+ def self.verify_response_with_json_node(json_node,string)
46
+ json = IFD_Soap.get_soap_response.body.to_json
47
+ results = JsonPath.new(json_node).on(json).to_a.map(&:to_s)
48
+ IFD_Assertion.assert_string_equal(string, results[0])
49
+ end
50
+
51
+ def self.verify_response_code(status_code)
52
+ IFD_Assertion.assert_string_equal(IFD_Soap.get_soap_response.http.code, status_code.to_i)
53
+ end
54
+
55
+ def self.print_response
56
+ p "SOAP RESPONSE: #{IFD_Soap.get_soap_response}"
57
+ end
58
+
59
+ end
@@ -0,0 +1,39 @@
1
+ require 'net/ssh'
2
+
3
+ class IFD_Ssh
4
+ def self.connect_to_server_with_credential(host_name,table)
5
+ hostname = Utils.check_dynamic_value host_name
6
+ @keys = []
7
+ @auth_methods ||= %w(password)
8
+ session = table.hashes.first
9
+ session_keys = Array.new(@keys)
10
+ session_auth_methods = Array.new(@auth_methods)
11
+ if session["keyfile"]
12
+ session_keys << session["keyfile"]
13
+ session_auth_methods << "publickey"
14
+ end
15
+
16
+ @SSHconnection = Net::SSH.start(hostname, session["username"], :password => session["password"],
17
+ :auth_methods => session_auth_methods,
18
+ :keys => session_keys)
19
+ end
20
+
21
+ def self.exec_command(command)
22
+ command = Utils.check_dynamic_value command
23
+ @output = @SSHconnection.exec!(command)
24
+ end
25
+
26
+ def self.print_output
27
+ p @output
28
+ end
29
+
30
+ def self.verify_output(string)
31
+ string = Utils.check_dynamic_value(string)
32
+ IFD_Assertion.assert_string_equal(string, @output.strip)
33
+ end
34
+
35
+ def self.store_result_string(name)
36
+ $context_value = Utils.bind_with_dyn_vars(@output)
37
+ Utils.set_var(name, '$context_value')
38
+ end
39
+ end
@@ -0,0 +1,447 @@
1
+ require 'net/https'
2
+ # Open Browser with config-able maximize browser option
3
+ def execute_openbrowser(url_site)
4
+ begin
5
+ if $_CFWEB['Maximize Browser'] == true
6
+ page.driver.browser.manage.window.maximize
7
+ end
8
+ rescue StandardError => myStandardError
9
+ raise "\n>>> Error: #{myStandardError}"
10
+ end
11
+
12
+ if url_site == ""
13
+ raise "\n>>> Error: Null web page URL."
14
+ else
15
+ visit(url_site)
16
+ end
17
+ end
18
+
19
+ def execute_click(element)
20
+ foundElement = find_object(element)
21
+ if foundElement != nil
22
+ page.driver.execute_script('window.focus();')
23
+ startTime = Time.new.to_i
24
+ begin
25
+ sleep(0.5)
26
+ currentTime = Time.new.to_i
27
+ end while (foundElement.native.enabled? == false and (currentTime - startTime) < $_CFWEB['Wait Time'])
28
+ page.driver.browser.execute_script("arguments[0].scrollIntoView(true);", foundElement.native)
29
+ page.driver.browser.action.move_to(foundElement.native, element).click.perform
30
+ # page.driver.browser.action.click(foundElement.native)
31
+ # foundElement.native.send_keys(:return)
32
+ else
33
+ raise "\nError >> Not found object: #{element}"
34
+ end
35
+ end
36
+
37
+ def double_click(element)
38
+ foundElement = find_object(element)
39
+ if foundElement != nil
40
+ begin
41
+ page.driver.browser.action.double_click(foundElement.native)
42
+ rescue StandardError => myStandardError
43
+ raise "\n>>> Error: #{myStandardError}"
44
+ end
45
+ else
46
+ raise "\nError >> Not found object: #{element}"
47
+ exit
48
+ end
49
+ end
50
+
51
+ def execute_settext(element, text)
52
+ foundElement = find_object(element)
53
+ if foundElement != nil
54
+ begin
55
+ foundElement.set(text)
56
+ rescue StandardError => myStandardError
57
+ raise "\n>>> Error: #{myStandardError}"
58
+ end
59
+ else
60
+ raise "\nError >> Not found object: #{element}"
61
+ exit
62
+ end
63
+ end
64
+
65
+ def maximize_browser
66
+ page.driver.browser.manage.window.maximize
67
+ end
68
+
69
+ def switch_to_window_by_title(window_title)
70
+ $previous_window = page.driver.browser.window_handle
71
+ window_found = false
72
+ page.driver.browser.window_handles.each { |handle|
73
+ page.driver.browser.switch_to.window handle
74
+ if page.title == window_title
75
+ window_found = true
76
+ break
77
+ end
78
+ }
79
+ raise "Window having title \"#{window_title}\" not found" if not window_found
80
+ end
81
+
82
+ def scroll_page(to)
83
+ if to == 'end'
84
+ page.driver.execute_script('window.scrollTo(0,Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight));')
85
+ elsif to == 'top'
86
+ page.driver.execute_script('window.scrollTo(Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight),0);')
87
+ else
88
+ raise "Exception : Invalid Direction (only scroll \"top\" or \"end\")"
89
+ end
90
+ end
91
+
92
+ # Method to verify title
93
+ # param 1 : String : expected title
94
+ # param 2 : Boolean : test case [true or flase]
95
+ def check_title(title, test_case)
96
+ page_title = page.title
97
+ if test_case
98
+ if page_title != "#{title}"
99
+ raise "Page Title Not Matched, Actual Page Title : #{page_title}, Expected Page Title : #{title}"
100
+ end
101
+ else
102
+ if page_title == "#{title}"
103
+ raise "Page Title Matched, Actual Page Title: #{page_title}"
104
+ end
105
+ end
106
+ end
107
+
108
+ def check_alert_text(text)
109
+ alert = page.driver.browser.switch_to.alert.text
110
+ if alert != text
111
+ raise "Text on alert pop up not matched, Actual Text : #{alert}, Expected Text : #{text}"
112
+ end
113
+ end
114
+
115
+ def execute_select(element, text)
116
+ #select(text, :xpath => element)
117
+ foundElement = find_object(element)
118
+
119
+ if foundElement != nil
120
+ option_value = page.evaluate_script("$(\"##{foundElement[:id]} option:contains('#{text}')\").val()")
121
+ page.execute_script("$('##{foundElement[:id]}').val('#{option_value}')")
122
+ page.execute_script("$('##{foundElement[:id]}').trigger('liszt:updated').trigger('change')")
123
+ else
124
+ put_log "\nError >> Not found object: #{element}"
125
+ exit
126
+ end
127
+ end
128
+
129
+ def execute_mousehoverandclick(element)
130
+ foundElement = find_object(element)
131
+ if foundElement != nil
132
+ page.driver.browser.action.move_to(foundElement.native, element).click.perform
133
+ sleep(1)
134
+ else
135
+ put_log "\nError >> Not found object: #{element}"
136
+ end
137
+ end
138
+
139
+ def remove_element_attribute(element, attr)
140
+ foundElement = find_object(element)
141
+ if foundElement != nil
142
+ page.driver.browser.execute_script("arguments[0].removeAttribute('#{attr}');", foundElement.native)
143
+ else
144
+ put_log "\nError >> Not found object: #{element}"
145
+ end
146
+ end
147
+
148
+ # Set state
149
+ def execute_setstate(element, state)
150
+ foundElement = find_object(element)
151
+ if foundElement != nil
152
+ if state.upcase == "TRUE"
153
+ foundElement.select_option
154
+ else
155
+ foundElement.unselect_option
156
+ end
157
+ else
158
+ put_log "\nError >> Not found object: #{element}"
159
+ exit
160
+ end
161
+ end
162
+
163
+ def resize_window_screen(x, y)
164
+ page.driver.browser.manage.window.resize_to(x, y)
165
+ puts page.driver.browser.manage.window.size
166
+ end
167
+
168
+ def get_computed_style(element, style)
169
+ foundElement = get_object_value(element)
170
+ computedStyle = ""
171
+ if foundElement != nil
172
+ computedStyle = page.evaluate_script(
173
+ "window.getComputedStyle(document.querySelector('#{foundElement}')).#{style}"
174
+ )
175
+ else
176
+ puts "\nError >> Not found object: #{element}"
177
+ end
178
+ puts "\nActual object style value is: #{computedStyle}"
179
+ computedStyle
180
+ end
181
+
182
+ require 'rspec'
183
+
184
+ def put_log str
185
+ p str if $_CFWEB['Print Log'] == true
186
+ end
187
+
188
+ def get_object_value(str_obj)
189
+ string_object = str_obj.gsub(/"/, "'")
190
+ hash_object = $OBJECT[string_object]
191
+ if hash_object == nil
192
+ raise ">>> OBJECT: #{str_obj} NAME MAYBE NOT FOUND!!!"
193
+ end
194
+ if hash_object.keys[0].to_s.upcase != "CSS_SELECTOR"
195
+ raise ">>> OBJECT: #{str_obj} should be formatted as Css Selector."
196
+ end
197
+ hash_object[hash_object.keys[0]]
198
+ end
199
+
200
+ def execute_checkproperty(element, property, negate, value, isSpecialChar=false)
201
+ Capybara.configure do |config|
202
+ config.ignore_hidden_elements = false
203
+ end
204
+ foundElement = find_object(element)
205
+
206
+ check = false
207
+ if foundElement == nil and value == ""
208
+ check = true
209
+ # check.should eq true
210
+ expect(check).to eq true
211
+ else
212
+ # put_log "\n\n\t>>> execute_checkproperty: finish to found element"
213
+ if foundElement != nil
214
+ if property.upcase == 'VALUE'
215
+ actual_value = foundElement.value()
216
+
217
+ elsif property.upcase == 'TEXT'
218
+ actual_value = foundElement.text()
219
+
220
+ elsif property.upcase == 'SPECIAL CHAR'
221
+ actual_value = foundElement.text()
222
+ isSpecialChar = true
223
+
224
+ elsif property.upcase == 'TAGNAME'
225
+ actual_value = foundElement.tag_name()
226
+
227
+ elsif property.upcase == 'STYLE'
228
+ actual_value = foundElement[:style]
229
+
230
+ elsif property.upcase == 'DISABLED'
231
+ actual_value = foundElement[:disabled]
232
+
233
+ elsif property.upcase == 'WIDTH'
234
+ actual_value = foundElement[:width]
235
+
236
+ elsif property.upcase == 'HEIGHT'
237
+ actual_value = foundElement[:height]
238
+
239
+ elsif property.upcase == 'ID'
240
+ actual_value = foundElement[:id]
241
+
242
+ elsif property.upcase == 'NAME'
243
+ actual_value = foundElement[:name]
244
+
245
+ elsif property.upcase == 'CLASS'
246
+ actual_value = foundElement[:class]
247
+
248
+ elsif property.upcase == 'HREF'
249
+ actual_value = foundElement[:href]
250
+
251
+ elsif property.upcase == 'TITLE'
252
+ actual_value = foundElement[:title]
253
+
254
+ elsif property.upcase == 'TYPE'
255
+ actual_value = foundElement[:type]
256
+
257
+ elsif property.upcase == 'CHECKED'
258
+ actual_value = "true" if foundElement.checked? == true
259
+ actual_value = "false" if foundElement.checked? == false
260
+ else
261
+ actual_value = foundElement["#{property}"]
262
+ end
263
+
264
+ if actual_value == nil
265
+ actual_value = ''
266
+ end
267
+ else
268
+ put_log "\nError >> Not found object: #{element}"
269
+ end
270
+
271
+ Capybara.configure do |config|
272
+ config.ignore_hidden_elements = true
273
+ end
274
+
275
+ # if IFD_Assertion.reg_compare(actual_value, value, isSpecialChar)
276
+ # check = true
277
+ # end
278
+
279
+ put_log "\n#{property} :: Actual result is: '#{actual_value}' -- Expected result is: '#{value}'"
280
+
281
+ if negate == " not"
282
+ actual_value.should_not eq value
283
+ expect(actual_value).not_to eql value
284
+ elsif actual_value.should eq value
285
+ expect(actual_value).to eq value
286
+ end
287
+ end
288
+ end
289
+
290
+ def execute_gettext(element)
291
+ foundElement = find_object(element)
292
+ if foundElement != nil
293
+ tagname = foundElement.tag_name()
294
+
295
+ if tagname.upcase == 'SELECT'
296
+ else
297
+ actual_text = foundElement.text()
298
+ if (actual_text == nil or actual_text.length == 0) and (tagname.upcase == 'INPUT' or tagname.upcase == 'TEXTAREA')
299
+ actual_text = foundElement.value()
300
+ end
301
+ end
302
+
303
+ put_log "\nText is '" + actual_text + "' of object '" + element + "'"
304
+ $context_value = actual_text
305
+ else
306
+ put_log "\nError >> Not found object: #{element}"
307
+ exit
308
+ end
309
+ end
310
+
311
+ def find_object(string_object)
312
+ startTime = Time.new.to_i
313
+ string_object = string_object.gsub(/"/, "'")
314
+ locator_matching = /(.*?)(\{.*?\})/.match(string_object)
315
+ dyn_pros = {}
316
+ if locator_matching != nil
317
+ string_object = locator_matching[1]
318
+ eval(locator_matching[2].gsub(/['][\s,\t]*?:[\s,\t]*?[']?/, "'=>'")).each { |k, v|
319
+ dyn_pros[k.to_s.upcase] = v
320
+ }
321
+ end
322
+
323
+ hash_object = $OBJECT[string_object]
324
+ if hash_object == nil
325
+ raise "ERROR: >>> Object: #{string_object} is not found in Object Repository."
326
+ end
327
+ upcase_attrb = {}
328
+ if hash_object != nil
329
+ hash_object.each { |k, v|
330
+ k = k.to_s.upcase
331
+ if k =~ /ph_/i
332
+ if dyn_pros[k] != nil
333
+ if v =~ /<ph_value>/i
334
+ upcase_attrb[k[3..k.size-1]] = v.gsub(/<ph_value>/i, dyn_pros[k])
335
+ else
336
+ upcase_attrb[k[3..k.size-1]] = dyn_pros[k]
337
+ end
338
+
339
+ dyn_pros.delete(k)
340
+ end
341
+ else
342
+ upcase_attrb[k.to_s.upcase] = v
343
+ end
344
+
345
+ }
346
+ end
347
+ ph_attrs = {}
348
+ dyn_pros.each { |k, v|
349
+ if k =~ /ph_/i
350
+ ph_attrs[k] = v
351
+ else
352
+ upcase_attrb[k.to_s.upcase] = v
353
+ end
354
+ }
355
+
356
+ if upcase_attrb.size > 0
357
+ strCssSelector = ""
358
+ strXpathSelector = ""
359
+
360
+
361
+ upcase_attrb.each { |key, value|
362
+ upcase_key = key.to_s.upcase
363
+ case upcase_key
364
+ when "XPATH_SELECTOR"
365
+ strXpathSelector = value
366
+ when "CSS_SELECTOR"
367
+ strCssSelector = value
368
+ else
369
+ raise "ERROR: >>> Wrong format type: #{key.to_s} of object: #{string_object}. Available supported format are: XPATH_SELECTOR and CSS_SELECTOR"
370
+ end
371
+ }
372
+
373
+ begin
374
+ if strCssSelector != nil and strCssSelector.length > 0
375
+ foundElements = get_objects_by_css_selector(strCssSelector)
376
+ else
377
+ foundElements = get_objects_by_xpath_selector(strXpathSelector)
378
+ end
379
+ if foundElements == nil or foundElements.length == 0
380
+ currentTime = Time.new.to_i
381
+ else
382
+ put_log "\nBREAK!!!"
383
+ break
384
+ end
385
+ test = currentTime - startTime
386
+ put_log "\n#TIMEOUNT:#{test} < #{$_CFWEB['Wait Time']}"
387
+ sleep(0.5)
388
+ end while (currentTime - startTime) < $_CFWEB['Wait Time']
389
+
390
+ if foundElements != nil or foundElements.length != 0
391
+ return_element = nil
392
+ foundElements.each { |cur_element|
393
+ passCheck = find_object_check_object(cur_element)
394
+ if passCheck
395
+ return_element = cur_element
396
+ break
397
+ end
398
+ }
399
+ return return_element
400
+ end
401
+ end
402
+
403
+ nil
404
+ end
405
+
406
+ def get_objects_by_css_selector(strCssSelector)
407
+ foundElements = nil
408
+ begin
409
+ foundElements = page.all(:css, strCssSelector)
410
+ rescue StandardError => myStandardError
411
+ raise "\n>>> Error: #{myStandardError}"
412
+ end
413
+
414
+ foundElements
415
+ end
416
+
417
+ def get_objects_by_xpath_selector(strXpathSelector)
418
+ foundElements = nil
419
+ begin
420
+ foundElements = page.all(:xpath, strXpathSelector)
421
+ rescue StandardError => myStandardError
422
+ put_log "\n>>> Error: #{myStandardError}"
423
+ end
424
+ foundElements
425
+ end
426
+
427
+ def find_object_check_object(cur_element)
428
+ passCheck = true
429
+ if cur_element != nil
430
+ return passCheck
431
+ end
432
+ false
433
+ end
434
+
435
+ def get_object_and_store_as_string(object,string)
436
+ text = execute_gettext(object)
437
+ txt = "'" + text + "'"
438
+ Utils.set_var(string, txt)
439
+ end
440
+
441
+
442
+ def get_object_and_store_to_file(object,file_name)
443
+ $text = execute_gettext(object)
444
+ open($test_data_dir+file_name, 'a+') do |f|
445
+ f << $text + "\n"
446
+ end
447
+ end