scoutui 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +10 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/CODE_OF_CONDUCT.md +13 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +154 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +14 -0
  11. data/bin/scoutui_driver.rb +22 -0
  12. data/bin/setup +7 -0
  13. data/examples/ex1/commands.holidays.yml +45 -0
  14. data/examples/ex1/commands.yml +25 -0
  15. data/examples/ex1/test-example.sh +38 -0
  16. data/examples/ex1/test.config.json +16 -0
  17. data/examples/ex2/commands.yml +35 -0
  18. data/examples/ex2/page_model.json +28 -0
  19. data/examples/ex2/test-example.sh +39 -0
  20. data/examples/ex2/test.config.json +25 -0
  21. data/lib/scoutui.rb +8 -0
  22. data/lib/scoutui/appmodel/q_model.rb +82 -0
  23. data/lib/scoutui/base/assertions.rb +62 -0
  24. data/lib/scoutui/base/q_accounts.rb +52 -0
  25. data/lib/scoutui/base/q_applitools.rb +127 -0
  26. data/lib/scoutui/base/q_browser.rb +185 -0
  27. data/lib/scoutui/base/q_form.rb +261 -0
  28. data/lib/scoutui/base/test_scout.rb +120 -0
  29. data/lib/scoutui/base/test_settings.rb +109 -0
  30. data/lib/scoutui/base/user_vars.rb +108 -0
  31. data/lib/scoutui/base/visual_test_framework.rb +574 -0
  32. data/lib/scoutui/commands/click_object.rb +45 -0
  33. data/lib/scoutui/commands/command.rb +56 -0
  34. data/lib/scoutui/commands/commands.rb +133 -0
  35. data/lib/scoutui/commands/exists_alert.rb +54 -0
  36. data/lib/scoutui/commands/fill_form.rb +56 -0
  37. data/lib/scoutui/commands/jsalert/action_jsalert.rb +58 -0
  38. data/lib/scoutui/commands/mouse_over.rb +31 -0
  39. data/lib/scoutui/commands/pause.rb +26 -0
  40. data/lib/scoutui/commands/select_object.rb +54 -0
  41. data/lib/scoutui/commands/strategy.rb +202 -0
  42. data/lib/scoutui/commands/submit_form.rb +44 -0
  43. data/lib/scoutui/commands/type.rb +44 -0
  44. data/lib/scoutui/commands/update_url.rb +45 -0
  45. data/lib/scoutui/commands/utils.rb +128 -0
  46. data/lib/scoutui/commands/verify_element.rb +198 -0
  47. data/lib/scoutui/commands/verify_form.rb +26 -0
  48. data/lib/scoutui/eyes/eye_factory.rb +76 -0
  49. data/lib/scoutui/eyes/eye_scout.rb +239 -0
  50. data/lib/scoutui/logger/log_mgr.rb +105 -0
  51. data/lib/scoutui/navigator.rb +24 -0
  52. data/lib/scoutui/utils/utils.rb +352 -0
  53. data/lib/scoutui/version.rb +3 -0
  54. data/scoutui.gemspec +35 -0
  55. metadata +54 -2
  56. data/pkg/scoutui-2.0.0.gem +0 -0
@@ -0,0 +1,108 @@
1
+ require 'singleton'
2
+ require 'faker'
3
+
4
+ module Scoutui::Base
5
+
6
+ class UserVars
7
+ include Singleton
8
+
9
+ attr_accessor :globals
10
+
11
+ def initialize
12
+ @globals={
13
+ :accounts => '/tmp/qa/accounts.yaml',
14
+ :browser => 'chrome',
15
+ :userid => nil,
16
+ :password => nil,
17
+ :host => nil,
18
+ :localization => 'en-us'
19
+ }
20
+ end
21
+
22
+ def dump()
23
+ @globals.each_pair do |k, v|
24
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " #{k} => #{v}"
25
+ end
26
+ end
27
+
28
+ def getViewPort()
29
+ arr=Scoutui::Base::UserVars.instance.getVar('eyes.viewport').match(/(\d+)\s*x\s*(\d+)$/i)
30
+ if arr.size==3
31
+ _sz = {:width => arr[1].to_i, :height => arr[2].to_i }
32
+ end
33
+
34
+ _sz
35
+ end
36
+
37
+ def getBrowserType()
38
+ @globals[:browser].to_sym
39
+ end
40
+
41
+ def getHost()
42
+ @globals[:host].to_s
43
+ end
44
+
45
+ def get(k)
46
+ foundKey=true
47
+
48
+ v=k
49
+
50
+ _rc = k.match(/\$\{(.*)\}$/)
51
+
52
+ # Needs refactoring!
53
+ if k=='${userid}'
54
+ k=:userid
55
+ elsif k=='${password}'
56
+ k=:password
57
+ elsif k=='${host}'
58
+ k=:host
59
+ elsif k.is_a?(Symbol)
60
+ foundKey=true
61
+ elsif k=='__random_email__'
62
+ return Faker::Internet.email
63
+ elsif !_rc.nil?
64
+ k=_rc[1].to_s
65
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " User Var found => #{k}" if Scoutui::Utils::TestUtils.instance.isDebug?
66
+ if Scoutui::Utils::TestUtils.instance.getTestConfig().has_key?("user_vars")
67
+
68
+ if Scoutui::Utils::TestUtils.instance.getTestConfig()["user_vars"].has_key?(k)
69
+ v=Scoutui::Utils::TestUtils.instance.getTestConfig()["user_vars"][k].to_s
70
+ end
71
+
72
+ end
73
+
74
+ else
75
+ foundKey=false
76
+ end
77
+
78
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " get(#{k}) => #{@globals.has_key?(k)}" if Scoutui::Utils::TestUtils.instance.isDebug?
79
+
80
+ if @globals.has_key?(k) && foundKey
81
+ v=@globals[k]
82
+ end
83
+
84
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " get(#{k} => #{@globals.has_key?(k)} ==> #{v.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
85
+
86
+ v
87
+ end
88
+
89
+ def set(k, v)
90
+ setVar(k, v)
91
+ v
92
+ end
93
+
94
+ def getVar(k)
95
+ @globals[k].to_s
96
+ end
97
+
98
+ def setVar(k, v)
99
+ @globals[k]=v
100
+ v
101
+ end
102
+
103
+
104
+ end
105
+
106
+
107
+
108
+ end
@@ -0,0 +1,574 @@
1
+ #require 'testmgr'
2
+
3
+ module Scoutui::Base
4
+
5
+ class VisualTestFramework
6
+
7
+ STEP_KEY='page'
8
+ CMD_KEY='dut' # Used to indicate the command file (YML) to execute
9
+
10
+ def initialize()
11
+
12
+ end
13
+
14
+
15
+ def self.processCommand(_action, e, my_driver)
16
+ _req = Scoutui::Utils::TestUtils.instance.getReq()
17
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " === Process ACTION : #{_action} ===" if Scoutui::Utils::TestUtils.instance.isDebug?
18
+
19
+ if Scoutui::Commands::Utils.instance.isExistsAlert?(_action)
20
+ _c = Scoutui::Commands::JsAlert::ExistsAlert.new(_action)
21
+ _rc = _c.execute(my_driver)
22
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " existsAlert => #{_rc}"
23
+
24
+ Scoutui::Logger::LogMgr.instance.asserts.info "Verify alert is present - #{!_rc.nil?.to_s}"
25
+ Testmgr::TestReport.instance.getReq(_req).get_child('expectJsAlert').add(!_rc.nil?, "Verify alert is present")
26
+
27
+ elsif Scoutui::Commands::Utils.instance.isVerifyForm?(_action)
28
+ _c = Scoutui::Commands::VerifyForm.new(_action)
29
+ _c.execute(my_driver)
30
+
31
+ elsif !_action.match(/fillform\(/).nil? && false
32
+
33
+ # _c = Scoutui::Commands::FillForm.new(_action)
34
+
35
+ _form = _action.match(/fillform\((.*)\s*\)/)[1].to_s
36
+ # _dut = _action.match(/fillform\(.*,\s*(.*)\)/)[1].to_s
37
+
38
+ dut = e[STEP_KEY]['dut']
39
+
40
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " DUT => #{dut}" if Scoutui::Utils::TestUtils.instance.isDebug?
41
+ _f = Scoutui::Utils::TestUtils.instance.getForm(_form)
42
+ _f.dump()
43
+ _f.verifyForm(my_driver)
44
+ _f.fillForm(my_driver, dut)
45
+
46
+ elsif !_action.match(/submitform\(/).nil? && false
47
+ _cmd = Scoutui::Commands::SubmitForm.new(_action)
48
+ # _cmd.execute(my_driver)
49
+
50
+ _form = _action.match(/submitform\((.*)\s*\)/)[1].to_s
51
+ _f = Scoutui::Utils::TestUtils.instance.getForm(_form)
52
+ _f.submitForm(my_driver)
53
+
54
+ elsif !_action.match(/type\(/).nil? && false
55
+ _xpath = _action.match(/type\((.*),\s*/)[1].to_s
56
+ _val = _action.match(/type\(.*,\s*(.*)\)/)[1].to_s
57
+
58
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + "Process TYPE #{_val} into #{_xpath}" if Scoutui::Utils::TestUtils.instance.isDebug?
59
+
60
+ obj = Scoutui::Base::QBrowser.getObject(my_driver, _xpath)
61
+
62
+ if !obj.nil? && !obj.attribute('type').downcase.match(/(text|password|email)/).nil?
63
+ Scoutui::Logger::LogMgr.instance.commands.info "send_keys(#{_val})"
64
+ obj.send_keys(Scoutui::Base::UserVars.instance.get(_val))
65
+ else
66
+ Scoutui::Logger::LogMgr.instance.warn __FILE__ + (__LINE__).to_s + " Unable to process command TYPE => #{obj.to_s}"
67
+ end
68
+
69
+ end
70
+
71
+
72
+ end
73
+
74
+ def self.isRun(e)
75
+ _run=nil
76
+ if e[STEP_KEY].has_key?("run")
77
+ _run = e[STEP_KEY].has_key?("run").to_s
78
+ end
79
+ _run
80
+ end
81
+
82
+ def self.isSnapIt(e)
83
+ _snapit=false
84
+
85
+ if e[STEP_KEY].has_key?("snapit")
86
+ _snapit = !(e[STEP_KEY]["snapit"].to_s.match(/true/i).nil?)
87
+ end
88
+ _snapit
89
+ end
90
+
91
+
92
+ def self.verifyCondition(my_driver, xpath)
93
+ rc=false
94
+
95
+ if !xpath.match(/^page\([\w\d]+\)/).nil?
96
+
97
+ page_elt = Scoutui::Utils::TestUtils.instance.getPageElement(xpath)
98
+
99
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Process page request #{page_elt} => #{page_elt.class.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
100
+
101
+ if page_elt.is_a?(Hash) && page_elt.has_key?('locator')
102
+
103
+ ##
104
+ # expected:
105
+ # wait: page(abc).get(def) where this page_elt has "locator"
106
+
107
+ xpath = page_elt['locator'].to_s
108
+
109
+ elsif xpath.is_a?(Hash)
110
+ xpath.each_pair do |_k, _v|
111
+
112
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " k,v :: #{_k.to_s}, #{_v.to_s}"
113
+
114
+ if _v.has_key?('locator')
115
+ _locator = _v['locator'].to_s
116
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " " + _k.to_s + " => " + _locator
117
+
118
+ # _locator = Scoutui::Utils::TestUtils.instance.getPageElement(_v['locator'])
119
+
120
+ _obj = Scoutui::Base::QBrowser.getFirstObject(my_driver, _locator)
121
+
122
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " HIT #{_locator} => #{!_obj.nil?}"
123
+ end
124
+
125
+ end
126
+
127
+
128
+ end
129
+
130
+ end
131
+
132
+ end
133
+
134
+
135
+ def self.processAssertions(my_driver, e)
136
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " === ProcessAssertions(#{e.to_s} ====" if Scoutui::Utils::TestUtils.instance.isDebug?
137
+
138
+ if !e[STEP_KEY].has_key?('assertions')
139
+ return
140
+ end
141
+
142
+ _req = Scoutui::Utils::TestUtils.instance.getReq()
143
+
144
+ puts __FILE__ + (__LINE__).to_s + "======= #{e[STEP_KEY]['assertions']} ========="
145
+
146
+
147
+ e[STEP_KEY]['assertions'].each do |elt|
148
+
149
+ begin
150
+
151
+
152
+ _k = elt.keys[0].to_s
153
+ a = elt[_k]
154
+
155
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Assert => #{_k} : #{a.to_s}"
156
+
157
+ # _k = 'generic-assertion'
158
+ _v={}
159
+
160
+ if a.is_a?(Hash)
161
+ _v=a
162
+
163
+
164
+ if _v.has_key?('locator')
165
+ _locator = _v['locator'].to_s
166
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " " + _k.to_s + " => " + _locator if Scoutui::Utils::TestUtils.instance.isDebug?
167
+
168
+ # _locator = Scoutui::Utils::TestUtils.instance.getPageElement(_v['locator'])
169
+
170
+ _obj = Scoutui::Base::QBrowser.getFirstObject(my_driver, _locator, Scoutui::Commands::Utils.instance.getTimeout())
171
+
172
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " HIT #{_locator} => #{!_obj.nil?}" if Scoutui::Utils::TestUtils.instance.isDebug?
173
+ end
174
+
175
+ if _v.has_key?('visible_when')
176
+
177
+ if _v['visible_when'].match(/always/i)
178
+ Scoutui::Logger::LogMgr.instance.asserts.info __FILE__ + (__LINE__).to_s + " Verify assertion #{_k} - #{_locator} visible - #{!_obj.nil?.to_s}"
179
+ Testmgr::TestReport.instance.getReq(_req).get_child('visible_when').add(!_obj.nil?, "Verify assertion #{_k} - #{_locator} visible")
180
+ elsif _v['visible_when'].match(/never/i)
181
+ Scoutui::Logger::LogMgr.instance.asserts.info "Verify assertion #{_k} #{_locator} not visible - #{obj.nil?.to_s}"
182
+ Testmgr::TestReport.instance.getReq(_req).get_child('visible_when').add(obj.nil?, "Verify assertion #{_k} #{_locator} not visible")
183
+ elsif _v['visible_when'].match(/role\=/i)
184
+ _role = _v['visible_when'].match(/role\=(.*)/i)[1].to_s
185
+ _expected_role = Scoutui::Utils::TestUtils.instance.getRole()
186
+
187
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Verify assertion object exists if the role #{_role} matches expected role #{_expected_role.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
188
+
189
+ if _role==_expected_role.to_s
190
+ Scoutui::Logger::LogMgr.instance.asserts.info "Verify assertion #{_k} #{_locator} visible when role #{_role} - #{!_obj.nil?.to_s}"
191
+ Testmgr::TestReport.instance.getReq(_req).get_child('visible_when').add(!_obj.nil?, "Verify assertion #{_k} #{_locator} visible when role #{_role}")
192
+ end
193
+
194
+ end
195
+ end
196
+
197
+
198
+ end
199
+
200
+ rescue => ex
201
+
202
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " abort processing."
203
+ Scoutui::Logger::LogMgr.instance.debug "Error during processing: #{ex}"
204
+ puts __FILE__ + (__LINE__).to_s + "Backtrace:\n\t#{ex.backtrace.join("\n\t")}"
205
+ end
206
+
207
+
208
+ end
209
+
210
+
211
+ end
212
+
213
+
214
+ def self.processExpected(my_driver, e)
215
+
216
+ _req = Scoutui::Utils::TestUtils.instance.getReq()
217
+
218
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + "\to Expected: #{e[STEP_KEY]['expected'].class.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
219
+
220
+ Scoutui::Base::Assertions.instance.setDriver(my_driver)
221
+
222
+ if e[STEP_KEY].has_key?('expected')
223
+ expected_list=e[STEP_KEY]['expected']
224
+
225
+ if expected_list.is_a?(Array)
226
+ expected_list.each do |_condition|
227
+ verifyCondition(my_driver, _condition)
228
+ end
229
+ end
230
+
231
+ if expected_list.is_a?(Hash)
232
+
233
+ expected_list.each_pair do |link_name, xpath|
234
+
235
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + "\t\t#{link_name} => #{xpath}" if Scoutui::Utils::TestUtils.instance.isDebug?
236
+
237
+ if !xpath.match(/\$\{.*\}/).nil?
238
+ xpath = Scoutui::Base::UserVars.instance.get(xpath)
239
+ end
240
+
241
+
242
+ if !xpath.match(/^page\([\w\d]+\)/).nil?
243
+
244
+
245
+ # Check if this is a form
246
+
247
+ page_elt = Scoutui::Utils::TestUtils.instance.getPageElement(xpath)
248
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Process page request #{page_elt} => #{page_elt.class.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
249
+
250
+ sub_elts=0
251
+ if page_elt.is_a?(Hash)
252
+ sub_elts = page_elt.select { |_s| page_elt[_s].has_key?("locator") if page_elt[_s].is_a?(Hash) && !page_elt[_s].nil? }.size
253
+ end
254
+
255
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " SubElts => #{sub_elts}" if Scoutui::Utils::TestUtils.instance.isDebug?
256
+
257
+ if page_elt.is_a?(Hash) && page_elt.has_key?('locator')
258
+
259
+ ##
260
+ # expected:
261
+ # wait: page(abc).get(def) where this page_elt has "locator"
262
+
263
+ xpath = page_elt['locator'].to_s
264
+
265
+ elsif sub_elts > 0
266
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Validate form" if Scoutui::Utils::TestUtils.instance.isDebug?
267
+
268
+ page_elt.each_pair do |_k, _v|
269
+
270
+ begin
271
+
272
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " k,v :: #{_k.to_s}, #{_v.to_s} (#{_v.class.to_s})" if Scoutui::Utils::TestUtils.instance.isDebug?
273
+
274
+ _obj=nil
275
+
276
+
277
+ if _v.is_a?(String)
278
+ puts __FILE__ + (__LINE__).to_s + " #{_v} is a string - next"
279
+ next
280
+ end
281
+
282
+ if _v.has_key?('assert_when') && _v['assert_when'].match(/role\s*\=/i)
283
+ _role = _v['assert_when'].match(/role\s*\=(.*)/i)[1].to_s
284
+ _expected_role = Scoutui::Utils::TestUtils.instance.getRole()
285
+
286
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Trigger: expected : #{_expected_role.to_s}, actual: #{_role.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
287
+
288
+ if !_expected_role.nil? && !_role.match(/#{_expected_role}/i)
289
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Skip assertion since conditional assertion #{_v['assert_when']} not met" if Scoutui::Utils::TestUtils.instance.isDebug?
290
+ next
291
+ elsif _expected_role.nil?
292
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Skip role based assertion since role was not provided" if Scoutui::Utils::TestUtils.instance.isDebug?
293
+ next
294
+ end
295
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Verify object exists since the role #{_role} matches expected role #{_expected_role.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
296
+ end
297
+
298
+
299
+ if Scoutui::Base::Assertions.instance.visible_when_skip(_k, _v)
300
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " SKIP #{_k.to_s} - #{_v.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
301
+ next
302
+ end
303
+
304
+ if _v.has_key?('locator')
305
+ _locator = _v['locator'].to_s
306
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " " + _k.to_s + " => " + _locator if Scoutui::Utils::TestUtils.instance.isDebug?
307
+
308
+ # _locator = Scoutui::Utils::TestUtils.instance.getPageElement(_v['locator'])
309
+
310
+ _obj = Scoutui::Base::QBrowser.getFirstObject(my_driver, _locator, Scoutui::Commands::Utils.instance.getTimeout())
311
+
312
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " HIT #{_locator} => #{!_obj.nil?}" if Scoutui::Utils::TestUtils.instance.isDebug?
313
+ end
314
+
315
+ if Scoutui::Base::Assertions.instance.visible_when_always(_k, _v, _obj)
316
+ next
317
+ elsif _v.has_key?('visible_when')
318
+
319
+ if _v['visible_when'].match(/always/i)
320
+ Scoutui::Logger::LogMgr.instance.asserts.info __FILE__ + (__LINE__).to_s + " Verify #{_k} - #{_locator} visible - #{!_obj.nil?.to_s}"
321
+ Testmgr::TestReport.instance.getReq(_req).get_child('visible_when').add(!_obj.nil?, "Verify #{_k} - #{_locator} visible")
322
+ elsif _v['visible_when'].match(/never/i)
323
+ Scoutui::Logger::LogMgr.instance.asserts.info "Verify #{_k} #{_locator} not visible - #{obj.nil?.to_s}"
324
+ Testmgr::TestReport.instance.getReq(_req).get_child('visible_when').add(obj.nil?, "Verify #{_k} #{_locator} not visible")
325
+ elsif _v['visible_when'].match(/role\=/i)
326
+ _role = _v['visible_when'].match(/role\=(.*)/i)[1].to_s
327
+ _expected_role = Scoutui::Utils::TestUtils.instance.getRole()
328
+
329
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Verify object exists if the role #{_role} matches expected role #{_expected_role.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
330
+
331
+ if _role==_expected_role.to_s
332
+ Scoutui::Logger::LogMgr.instance.asserts.info "Verify #{_k} #{_locator} visible when role #{_role} - #{!_obj.nil?.to_s}"
333
+ Testmgr::TestReport.instance.getReq(_req).get_child('visible_when').add(!_obj.nil?, "Verify #{_k} #{_locator} visible when role #{_role}")
334
+ end
335
+
336
+ end
337
+ end
338
+
339
+
340
+ rescue => ex
341
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Invalid file: #{datafile} - abort processing."
342
+ puts __FILE__ + (__LINE__).to_s + "Backtrace:\n\t#{ex.backtrace.join("\n\t")}"
343
+ end
344
+
345
+
346
+ end
347
+
348
+ return
349
+
350
+
351
+ elsif xpath.is_a?(Hash)
352
+ xpath.each_pair do |_k, _v|
353
+
354
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " k,v :: #{_k.to_s}, #{_v.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
355
+
356
+ if _v.has_key?('locator')
357
+ _locator = _v['locator'].to_s
358
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " " + _k.to_s + " => " + _locator if Scoutui::Utils::TestUtils.instance.isDebug?
359
+
360
+ # _locator = Scoutui::Utils::TestUtils.instance.getPageElement(_v['locator'])
361
+
362
+ _obj = Scoutui::Base::QBrowser.getFirstObject(my_driver, _locator)
363
+
364
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " HIT #{_locator} => #{!_obj.nil?}" if Scoutui::Utils::TestUtils.instance.isDebug?
365
+ end
366
+
367
+ end
368
+
369
+ next
370
+ end
371
+
372
+
373
+ end
374
+
375
+ obj = Scoutui::Base::QBrowser.getFirstObject(my_driver, xpath)
376
+
377
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " obj : #{obj}"
378
+
379
+ Scoutui::Logger::LogMgr.instance.asserts.info __FILE__ + (__LINE__).to_s + " Verify #{xpath} visible - #{obj.kind_of?(Selenium::WebDriver::Element).to_s}"
380
+
381
+ Testmgr::TestReport.instance.getReq(_req).get_child('visible_when').add(!obj.nil?, __FILE__ + (__LINE__).to_s + " Verify #{xpath} visible")
382
+
383
+ if obj.nil?
384
+ Scoutui::Logger::LogMgr.instance.warn " NOT FOUND : #{link_name} with xpath #{xpath}" if Scoutui::Utils::TestUtils.instance.isDebug?
385
+ else
386
+ Scoutui::Logger::LogMgr.instance.warn " link object(#{link_name} with xpath #{xpath}=> #{obj.displayed?}" if Scoutui::Utils::TestUtils.instance.isDebug?
387
+ end
388
+
389
+ end
390
+ end
391
+ end
392
+
393
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " [end]: processExpected()"
394
+ end
395
+
396
+ # Scoutui::Base::VisualTestFramework.processFile(@drv, @eyes, @test_settings['host'], @test_settings['dut'])
397
+ def self.processFile(eyeScout, test_settings, strategy=nil)
398
+
399
+ puts __FILE__ + (__LINE__).to_s + " [enter]:processFile(#{test_settings['dut']})"
400
+ my_driver = eyeScout.drv()
401
+
402
+ baseUrl = Scoutui::Base::UserVars.instance.getHost()
403
+ datafile = test_settings['dut']
404
+
405
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " processFile(#{eyeScout}, #{baseUrl}, #{datafile})" if Scoutui::Utils::TestUtils.instance.isDebug?
406
+
407
+ valid_file=false
408
+ i=0
409
+ begin
410
+ dut_dupes = YAML.load_stream File.read(datafile)
411
+ valid_file=true
412
+ rescue => ex
413
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Invalid file: #{datafile} - abort processing."
414
+ Scoutui::Logger::LogMgr.instance.info ex.backtrace
415
+ end
416
+
417
+ return if !valid_file
418
+
419
+ dut_dupes.each do |e|
420
+
421
+ totalWindows = my_driver.window_handles.length
422
+
423
+ Scoutui::Logger::LogMgr.instance.info '-' * 72 if Scoutui::Utils::TestUtils.instance.isDebug?
424
+ Scoutui::Logger::LogMgr.instance.info " [Pre-cmd]: Total Windows : #{totalWindows.to_s}"
425
+ Scoutui::Logger::LogMgr.instance.info "#{i.to_s}. Processing #{e.inspect}" if Scoutui::Utils::TestUtils.instance.isDebug?
426
+ i+=1
427
+
428
+ Scoutui::Utils::TestUtils.instance.setReq('UI')
429
+ Scoutui::Commands::Utils.instance.resetTimeout()
430
+
431
+ _action = e[STEP_KEY]["action"]
432
+ _name = e[STEP_KEY]["name"]
433
+ _url = e[STEP_KEY]["url"]
434
+ _skip = e[STEP_KEY]["skip"]
435
+ _region = e[STEP_KEY]["region"]
436
+ _reqid = e[STEP_KEY]["reqid"]
437
+
438
+ if e[STEP_KEY].has_key?("timeout")
439
+ Scoutui::Commands::Utils.instance.setTimeout(e[STEP_KEY]["timeout"])
440
+ end
441
+
442
+
443
+
444
+
445
+ if Scoutui::Utils::TestUtils.instance.isDebug?
446
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " action: #{_action}"
447
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " name: #{_name}"
448
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " url : #{_url}"
449
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " skip: #{_skip}"
450
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " region: #{_region}"
451
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " reqid: #{_reqid}"
452
+ end
453
+
454
+ if !_reqid.nil? && !_reqid.to_s.empty?
455
+ Testmgr::TestReport.instance.getReq(_reqid)
456
+ Scoutui::Utils::TestUtils.instance.setReq(_reqid)
457
+ else
458
+ puts __FILE__ + (__LINE__).to_s + " REQID was not provided"
459
+ end
460
+
461
+ skipIt = (!_skip.nil?) && (_skip.to_s.strip.downcase=='true')
462
+ Scoutui::Logger::LogMgr.instance.info "\to skip : #{skipIt}" if Scoutui::Utils::TestUtils.instance.isDebug?
463
+
464
+ if skipIt
465
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " SKIP - #{_name}" if Scoutui::Utils::TestUtils.instance.isDebug?
466
+ next
467
+ end
468
+
469
+
470
+ if !isRun(e).nil?
471
+
472
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " ========> RUN <================="
473
+ tmpSettings=test_settings.dup
474
+ tmpSettings["dut"]=e[STEP_KEY]["run"].to_s
475
+
476
+ Scoutui::Logger::LogMgr.instance.info " RUN Command file : #{tmpSettings["dut"]}"
477
+ processFile(eyeScout, tmpSettings, strategy)
478
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Completed execution of subfile"
479
+ next
480
+
481
+ end
482
+
483
+ if !(_action.nil? || _action.to_s.empty?)
484
+
485
+ # if !Scoutui::Commands::processCommand(_action, e, my_driver)
486
+
487
+ Scoutui::Logger::LogMgr.instance.asserts.info "Verify #{_action} is valid - #{Scoutui::Commands::Utils.instance.isValid?(_action).to_s}"
488
+ Testmgr::TestReport.instance.getReq('Command').get_child('isValid').add(Scoutui::Commands::Utils.instance.isValid?(_action), "Verify #{_action} is valid")
489
+
490
+ begin
491
+
492
+
493
+ _command = eyeScout.getStrategy().processCommand(_action, e)
494
+
495
+ if my_driver.window_handles.length > totalWindows
496
+ Scoutui::Logger::LogMgr.instance.info "[post-cmd] Total Windows : #{my_driver.window_handles.length.to_s}"
497
+ end
498
+
499
+
500
+ # if !eyeScout.getStrategy().processCommand(_action, e)
501
+ if !_command.wasExecuted?
502
+ processCommand(_action, e, my_driver)
503
+ end
504
+
505
+ processExpected(my_driver, e)
506
+ processAssertions(my_driver, e)
507
+
508
+
509
+ if isSnapIt(e)
510
+ if !_region.nil?
511
+ eyeScout.check_window(_name, _region)
512
+ else
513
+ eyeScout.check_window(_name)
514
+ end
515
+ end
516
+
517
+ rescue => ex
518
+ "Backtrace:\n\t#{ex.backtrace.join("\n\t")}"
519
+ end
520
+
521
+ next
522
+ end
523
+
524
+
525
+ if e[STEP_KEY].has_key?("url")
526
+ url = e[STEP_KEY]["url"].to_s
527
+
528
+
529
+ eyeScout.getStrategy().processCommand('navigate(' + url + ')', e)
530
+ end
531
+
532
+
533
+ Scoutui::Logger::LogMgr.instance.info "\to Expected: #{e[STEP_KEY]['expected'].class.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
534
+
535
+ processExpected(my_driver, e)
536
+ processAssertions(my_driver, e)
537
+
538
+ if !_region.nil?
539
+ eyeScount.check_window(_name, _region)
540
+ else
541
+ eyeScout.check_window(_name)
542
+ end
543
+
544
+ Scoutui::Logger::LogMgr.instance.info "\to links : #{e[STEP_KEY]['links'].class.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
545
+
546
+ if e[STEP_KEY].has_key?('links')
547
+ links=e[STEP_KEY]['links']
548
+
549
+ links.each_pair do |link_name, xpath|
550
+ Scoutui::Logger::LogMgr.instance.info "\t\t#{link_name} => #{xpath}" if Scoutui::Utils::TestUtils.instance.isDebug?
551
+
552
+
553
+ obj = QBrowser.getObject(my_driver, xpath)
554
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " [click]: link object => #{obj.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
555
+ obj.click
556
+
557
+ if !_region.nil?
558
+ eyeScount.check_window(_name, _region)
559
+ else
560
+ eyeScout.check_window(link_name)
561
+ end
562
+
563
+ end
564
+ end
565
+
566
+ end
567
+
568
+
569
+ end
570
+
571
+ end
572
+
573
+
574
+ end