scoutui 2.0.1 → 2.0.2

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/examples/capabilities/win10.chrome46.json +6 -0
  3. data/examples/ex1/test-example.sh +4 -4
  4. data/examples/ex1/test.config.json +1 -1
  5. data/examples/ex2/appmodel/common.json +51 -0
  6. data/examples/ex2/appmodel/page_model.json +106 -0
  7. data/examples/ex2/appmodel/register.model.json +42 -0
  8. data/examples/ex2/commands/commands.basic.appmodel.yml +8 -0
  9. data/examples/ex2/commands/commands.yml +115 -0
  10. data/examples/ex2/commands/ex1.yml +7 -0
  11. data/examples/ex2/commands/ex1c.yml +8 -0
  12. data/examples/ex2/commands/ex1d.yml +22 -0
  13. data/examples/ex2/commands/ex2.hover.yml +43 -0
  14. data/examples/ex2/commands/ex2.yml +24 -0
  15. data/examples/ex2/data.json +6 -0
  16. data/examples/ex2/test-configs/test.config.basic.json +12 -0
  17. data/examples/ex2/{test.config.json → test-configs/test.config.json} +8 -2
  18. data/examples/ex2/tests/run-test.sh +125 -0
  19. data/examples/ex2/tests/test-basic-appmodel.sh +14 -0
  20. data/examples/ex2/{test-example.sh → tests/test-example.sh} +3 -3
  21. data/examples/ex2/tests/test-example1a.sh +16 -0
  22. data/examples/ex2/tests/test-example1b.sh +13 -0
  23. data/examples/ex2/tests/test-example1c.sh +15 -0
  24. data/examples/ex2/tests/test-example1d.sh +15 -0
  25. data/examples/ex2/tests/test-example2.forms.eyes.sh +40 -0
  26. data/examples/ex2/tests/test-example2.hover.eyes.sh +40 -0
  27. data/examples/ex2/tests/test-example2.hover.sh +26 -0
  28. data/examples/ex2/tests/test-example2.sh +43 -0
  29. data/examples/ex2/tests/test-example3.sauce.sh +77 -0
  30. data/examples/ex2/tests/test-example3.sh +41 -0
  31. data/lib/scoutui/appmodel/q_model.rb +105 -0
  32. data/lib/scoutui/base/assertions.rb +570 -10
  33. data/lib/scoutui/base/q_applitools.rb +2 -2
  34. data/lib/scoutui/base/q_browser.rb +38 -5
  35. data/lib/scoutui/base/q_form.rb +7 -7
  36. data/lib/scoutui/base/test_scout.rb +2 -1
  37. data/lib/scoutui/base/user_vars.rb +29 -2
  38. data/lib/scoutui/base/visual_test_framework.rb +308 -24
  39. data/lib/scoutui/commands/click_object.rb +86 -13
  40. data/lib/scoutui/commands/commands.rb +20 -7
  41. data/lib/scoutui/commands/jsalert/action_jsalert.rb +1 -1
  42. data/lib/scoutui/commands/mouse_over.rb +94 -8
  43. data/lib/scoutui/commands/select_object.rb +1 -1
  44. data/lib/scoutui/commands/select_window.rb +43 -0
  45. data/lib/scoutui/commands/strategy.rb +40 -3
  46. data/lib/scoutui/commands/type.rb +99 -11
  47. data/lib/scoutui/commands/update_url.rb +1 -1
  48. data/lib/scoutui/commands/utils.rb +43 -5
  49. data/lib/scoutui/commands/verify_element.rb +38 -7
  50. data/lib/scoutui/eyes/eye_factory.rb +7 -1
  51. data/lib/scoutui/eyes/eye_scout.rb +20 -7
  52. data/lib/scoutui/utils/utils.rb +59 -1
  53. data/lib/scoutui/version.rb +1 -1
  54. data/scoutui.gemspec +5 -4
  55. metadata +77 -39
  56. data/examples/ex2/commands.yml +0 -35
  57. data/examples/ex2/page_model.json +0 -28
@@ -1,6 +1,6 @@
1
1
 
2
- require 'eyes_selenium'
3
- require 'httparty'
2
+ #require 'eyes_selenium'
3
+ #require 'httparty'
4
4
 
5
5
 
6
6
  module Scoutui::Base
@@ -1,6 +1,6 @@
1
1
 
2
- require 'eyes_selenium'
3
- require 'selenium-webdriver'
2
+ #require 'eyes_selenium'
3
+ #require 'selenium-webdriver'
4
4
 
5
5
  module Scoutui::Base
6
6
 
@@ -35,9 +35,37 @@ module Scoutui::Base
35
35
  rc
36
36
  end
37
37
 
38
- def self.getFirstObject(drv, _locator, _timeout=30)
39
38
 
40
- Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " getFirstObject(#{_locator})" if Scoutui::Utils::TestUtils.instance.isDebug?
39
+ def self.existsAlert?(drv)
40
+ rc=false
41
+
42
+ begin
43
+ alert=drv.switch_to.alert
44
+
45
+ if alert.is_a?(Selenium::WebDriver::Alert)
46
+ rc=true
47
+ end
48
+
49
+
50
+ rescue Selenium::WebDriver::Error::NoSuchAlertError
51
+ ;
52
+ end
53
+
54
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " existsAlert?() => #{rc}"
55
+ rc
56
+ end
57
+
58
+ def self.getFirstObject(drv, _locator, _timeout=nil)
59
+
60
+ if _timeout.nil?
61
+ _timeout = Scoutui::Utils::TestUtils.instance.getDefaultWait
62
+ end
63
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " getFirstObject(#{_locator}, #{_timeout})"
64
+
65
+ if _timeout > 30
66
+ Scoutui::Logger::LogMgr.instance.warn __FILE__ + (__LINE__).to_s + " A #{_timeout} second timeout is set high, may slow down tests"
67
+ end
68
+
41
69
  rc=nil
42
70
  locator=_locator
43
71
 
@@ -64,7 +92,12 @@ module Scoutui::Base
64
92
  end
65
93
 
66
94
  # http://stackoverflow.com/questions/15164742/combining-implicit-wait-and-explicit-wait-together-results-in-unexpected-wait-ti#answer-15174978
67
- def self.getObject(drv, obj, _timeout=30)
95
+ def self.getObject(drv, obj, _timeout=nil)
96
+
97
+ if _timeout.nil?
98
+ _timeout = Scoutui::Utils::TestUtils.instance.getDefaultWait
99
+ end
100
+
68
101
  Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " getObject(#{obj}) class:#{obj.class.to_s} hash : #{obj.is_a?(Hash)}" if Scoutui::Utils::TestUtils.instance.isDebug?
69
102
  rc=nil
70
103
  visible_when=nil
@@ -38,7 +38,7 @@ module Scoutui::Base
38
38
 
39
39
  _action=nil
40
40
 
41
- obj = Scoutui::Base::QBrowser.getObject(drv, locator)
41
+ obj = Scoutui::Base::QBrowser.getObject(drv, locator, Scoutui::Commands::Utils.instance.getTimeout)
42
42
  _type = obj.attribute('type').to_s
43
43
  _tag = obj.tag_name.to_s
44
44
 
@@ -111,7 +111,7 @@ module Scoutui::Base
111
111
  if v.is_a?(Hash) && v.has_key?(k) && v.has_key?('locator')
112
112
 
113
113
 
114
- obj = Scoutui::Base::QBrowser.getObject(drv, v['locator'])
114
+ obj = Scoutui::Base::QBrowser.getObject(drv, v['locator'], Scoutui::Commands::Utils.instance.getTimeout)
115
115
 
116
116
  if !v[k].match(/always/i).nil?
117
117
  _rc = !obj.nil? && obj.is_a?(Selenium::WebDriver::Element) && obj.displayed?
@@ -143,18 +143,18 @@ module Scoutui::Base
143
143
 
144
144
  Scoutui::Logger::LogMgr.instance.commands.debug __FILE__ + (__LINE__).to_s + " <cond, obj, when>::<#{_cond}, #{_obj}, #{_expected_val}"
145
145
 
146
- depObj = Scoutui::Base::QBrowser.getObject(drv, _obj)
146
+ depObj = Scoutui::Base::QBrowser.getObject(drv, _obj, Scoutui::Commands::Utils.instance.getTimeout)
147
147
  Scoutui::Logger::LogMgr.instance.commands.debug __FILE__ + (__LINE__).to_s + " hit => #{depObj.class.to_s} tag:#{depObj.tag_name}" if !depObj.nil?
148
148
 
149
149
  desc=nil
150
150
  if _expected_val.match(/true/i)
151
- obj = Scoutui::Base::QBrowser.getObject(drv, v['locator'])
151
+ obj = Scoutui::Base::QBrowser.getObject(drv, v['locator'], Scoutui::Commands::Utils.instance.getTimeout)
152
152
 
153
153
  _rc = !depObj.nil? && depObj.displayed? && !obj.nil? && obj.displayed?
154
154
  Scoutui::Logger::LogMgr.instance.asserts.info "Verify #{v['locator']} is displayed since #{_obj} is displayed - #{_rc.to_s}"
155
155
  Testmgr::TestReport.instance.getReq(_req).tc(k).add(_rc, "Verify #{v['locator']} is displayed since #{_obj} is displayed")
156
156
  elsif _expected_val.match(/false/i)
157
- obj = Scoutui::Base::QBrowser.getObject(drv, v['locator'])
157
+ obj = Scoutui::Base::QBrowser.getObject(drv, v['locator'], Scoutui::Commands::Utils.instance.getTimeout)
158
158
 
159
159
  _rc = depObj.nil? && !obj.nil? && obj.displayed?
160
160
  Scoutui::Logger::LogMgr.instance.asserts.info "Verify #{v['locator']} is displayed since #{_obj} is not visible. - #{_rc.to_s}"
@@ -166,7 +166,7 @@ module Scoutui::Base
166
166
  _obj=_match[1]
167
167
  _expected_val=_match[2]
168
168
 
169
- obj = Scoutui::Base::QBrowser.getObject(drv, _obj)
169
+ obj = Scoutui::Base::QBrowser.getObject(drv, _obj, Scoutui::Commands::Utils.instance.getTimeout)
170
170
  Scoutui::Logger::LogMgr.instance.commands.debug __FILE__ + (__LINE__).to_s + " hit => #{obj.class.to_s} tag:#{obj.tag_name}"
171
171
 
172
172
 
@@ -220,7 +220,7 @@ module Scoutui::Base
220
220
 
221
221
  if !drv.nil?
222
222
  @drv=drv
223
- obj = Scoutui::Base::QBrowser.getObject(drv, _xpath)
223
+ obj = Scoutui::Base::QBrowser.getObject(drv, _xpath, Scoutui::Commands::Utils.instance.getTimeout)
224
224
 
225
225
  _type = obj.attribute('type').to_s
226
226
  _tag = obj.tag_name.to_s
@@ -101,7 +101,8 @@ module Scoutui::Base
101
101
  teardown()
102
102
 
103
103
  rescue => ex
104
- Scoutui::Logger::LogMgr.instance.debug ex.backtrace
104
+ Scoutui::Logger::LogMgr.instance.warn __FILE__ + (__LINE__).to_s + " Error during processing: #{ex}"
105
+ Scoutui::Logger::LogMgr.instance.warn ex.backtrace
105
106
  ensure
106
107
  Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__ ).to_s + " Close Eyes" if Scoutui::Utils::TestUtils.instance.isDebug?
107
108
  @eyeScout.closeOut()
@@ -42,9 +42,34 @@ module Scoutui::Base
42
42
  @globals[:host].to_s
43
43
  end
44
44
 
45
- def get(k)
45
+ def normalize(s)
46
+ _vars = s.scan(/(\$\{.*?\})/)
47
+ _vars.each do | _v|
48
+ if _v.length==1
49
+
50
+ _u = Scoutui::Base::UserVars.instance.get(_v[0].to_s)
51
+ puts __FILE__ + (__LINE__).to_s + " Normalize(#{_v}) => #{_u}"
52
+
53
+ s.gsub!(_v[0].to_s, _u)
54
+ end
55
+
56
+ end
57
+
58
+ s
59
+ end
60
+
61
+ def get(_k)
62
+
63
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " get(#{_k})"
46
64
  foundKey=true
47
65
 
66
+ k=_k
67
+
68
+ if _k.is_a?(Array)
69
+ k=_k[0].to_s
70
+ end
71
+
72
+
48
73
  v=k
49
74
 
50
75
  _rc = k.match(/\$\{(.*)\}$/)
@@ -56,13 +81,15 @@ module Scoutui::Base
56
81
  k=:password
57
82
  elsif k=='${host}'
58
83
  k=:host
84
+ elsif k=='${lang}'
85
+ k=:lang
59
86
  elsif k.is_a?(Symbol)
60
87
  foundKey=true
61
88
  elsif k=='__random_email__'
62
89
  return Faker::Internet.email
63
90
  elsif !_rc.nil?
64
91
  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?
92
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " User Var found => #{k}"
66
93
  if Scoutui::Utils::TestUtils.instance.getTestConfig().has_key?("user_vars")
67
94
 
68
95
  if Scoutui::Utils::TestUtils.instance.getTestConfig()["user_vars"].has_key?(k)
@@ -12,6 +12,189 @@ module Scoutui::Base
12
12
  end
13
13
 
14
14
 
15
+ def self.processPageElement(my_driver, k, xpath)
16
+
17
+ puts __FILE__ + (__LINE__).to_s + " processPageElement(#{xpath})"
18
+ processed=false
19
+ _obj=nil
20
+
21
+ if !xpath.match(/^\s*page\(.*\)\s*$/).nil?
22
+
23
+ processed=true
24
+
25
+ # Check if this is a form
26
+
27
+ page_elt = Scoutui::Utils::TestUtils.instance.getPageElement(xpath)
28
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Process page request #{page_elt} => #{page_elt.class.to_s}"
29
+
30
+
31
+ sub_elts=0
32
+ if page_elt.is_a?(Hash)
33
+ sub_elts = page_elt.select { |_s| page_elt[_s].has_key?("locator") if page_elt[_s].is_a?(Hash) && !page_elt[_s].nil? }.size
34
+ end
35
+
36
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " SubElts => #{sub_elts}"
37
+
38
+ if page_elt.is_a?(Hash) && page_elt.has_key?('locator')
39
+
40
+ ##
41
+ # expected:
42
+ # wait: page(abc).get(def) where this page_elt has "locator"
43
+
44
+ xpath = page_elt['locator'].to_s
45
+
46
+ _obj = Scoutui::Base::QBrowser.getFirstObject(my_driver, xpath, Scoutui::Commands::Utils.instance.getTimeout)
47
+
48
+
49
+
50
+
51
+ _req = nil
52
+
53
+ if page_elt.has_key?('reqid')
54
+ _req=page_elt['reqid'].to_s
55
+ end
56
+
57
+ Scoutui::Base::Assertions.instance.assertPageElement(k, page_elt, _obj, my_driver, _req)
58
+
59
+
60
+
61
+ elsif sub_elts > 0
62
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Validate form"
63
+
64
+
65
+
66
+ page_elt.each_pair do |_k, _v|
67
+
68
+ begin
69
+
70
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " k,v :: #{_k.to_s}, #{_v.to_s} (#{_v.class.to_s})"
71
+
72
+ _obj=nil
73
+
74
+ if _v.is_a?(Array)
75
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Arrays - TBD => #{_v}"
76
+ end
77
+
78
+
79
+ if _v.is_a?(String)
80
+ puts __FILE__ + (__LINE__).to_s + " #{_v} is a string - next"
81
+ next
82
+ end
83
+
84
+ if _v.has_key?('assert_when') && _v['assert_when'].match(/role\s*\=/i)
85
+ _role = _v['assert_when'].match(/role\s*\=(.*)/i)[1].to_s
86
+ _expected_role = Scoutui::Utils::TestUtils.instance.getRole()
87
+
88
+ 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?
89
+
90
+ if !_expected_role.nil? && !_role.match(/#{_expected_role}/i)
91
+ 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?
92
+ next
93
+ elsif _expected_role.nil?
94
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Skip role based assertion since role was not provided" if Scoutui::Utils::TestUtils.instance.isDebug?
95
+ next
96
+ end
97
+ 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?
98
+ end
99
+
100
+
101
+ if Scoutui::Base::Assertions.instance.visible_when_skip(_k, _v)
102
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " SKIP #{_k.to_s} - #{_v.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
103
+ next
104
+ end
105
+
106
+ _req = nil
107
+
108
+ if _v.has_key?('reqid')
109
+ _req=_v['reqid'].to_s
110
+ end
111
+
112
+ if _v.has_key?('locator')
113
+ _locator = _v['locator'].to_s
114
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " " + _k.to_s + " => " + _locator
115
+
116
+ # _locator = Scoutui::Utils::TestUtils.instance.getPageElement(_v['locator'])
117
+
118
+ _obj = Scoutui::Base::QBrowser.getFirstObject(my_driver, _locator, Scoutui::Commands::Utils.instance.getTimeout())
119
+
120
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " HIT #{_locator} => #{(!_obj.nil?).to_s}" # if Scoutui::Utils::TestUtils.instance.isDebug?
121
+ end
122
+
123
+ if Scoutui::Base::Assertions.instance.visible_when_always(_k, _v, _obj, _req)
124
+ next
125
+ elsif Scoutui::Base::Assertions.instance.visible_when_never(_k, _v, _obj, _req)
126
+ next
127
+ elsif Scoutui::Base::Assertions.instance.visible_when_title(_k, _v, _obj, my_driver, _req)
128
+ next
129
+ elsif Scoutui::Base::Assertions.instance.visible_when_value(_k, _v, my_driver, _req)
130
+ next
131
+ elsif _v.has_key?('visible_when') && !_v['visible_when'].is_a?(Array)
132
+
133
+ if _v['visible_when'].match(/role\=/i)
134
+ _role = _v['visible_when'].match(/role\=(.*)/i)[1].to_s
135
+ _expected_role = Scoutui::Utils::TestUtils.instance.getRole()
136
+
137
+ 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?
138
+
139
+ if _role==_expected_role.to_s
140
+ Scoutui::Logger::LogMgr.instance.asserts.info "Verify #{_k} #{_locator} visible when role #{_role} - #{!_obj.nil?.to_s}"
141
+ Testmgr::TestReport.instance.getReq(_req).get_child('visible_when').add(!_obj.nil?, "Verify #{_k} #{_locator} visible when role #{_role}")
142
+ end
143
+
144
+ end
145
+ elsif _v.has_key?('visible_when') && _v['visible_when'].is_a?(Array)
146
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " visible_when : (Array) - TBD #{_v['visible_when']}"
147
+
148
+ _v['visible_when'].each do |_vwhen|
149
+ puts __FILE__ + (__LINE__).to_s + " #{_vwhen} #{_vwhen.class}"
150
+
151
+ Scoutui::Base::Assertions.instance.assertPageElement(_k, _vwhen, _obj, my_driver, _req)
152
+
153
+
154
+ end
155
+ end
156
+
157
+
158
+ rescue => ex
159
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Error during processing: #{ex}"
160
+ puts __FILE__ + (__LINE__).to_s + "Backtrace:\n\t#{ex.backtrace.join("\n\t")}"
161
+ end
162
+
163
+
164
+ end
165
+
166
+ return
167
+
168
+
169
+ elsif xpath.is_a?(Hash)
170
+ xpath.each_pair do |_k, _v|
171
+
172
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " k,v :: #{_k.to_s}, #{_v.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
173
+
174
+ if _v.has_key?('locator')
175
+ _locator = _v['locator'].to_s
176
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " " + _k.to_s + " => " + _locator if Scoutui::Utils::TestUtils.instance.isDebug?
177
+
178
+ # _locator = Scoutui::Utils::TestUtils.instance.getPageElement(_v['locator'])
179
+
180
+ _obj = Scoutui::Base::QBrowser.getFirstObject(my_driver, _locator)
181
+
182
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " HIT #{_locator} => #{!_obj.nil?}" if Scoutui::Utils::TestUtils.instance.isDebug?
183
+ end
184
+
185
+ end
186
+
187
+ # next
188
+ end
189
+
190
+
191
+ end
192
+
193
+ _obj
194
+
195
+ end
196
+
197
+
15
198
  def self.processCommand(_action, e, my_driver)
16
199
  _req = Scoutui::Utils::TestUtils.instance.getReq()
17
200
  Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " === Process ACTION : #{_action} ===" if Scoutui::Utils::TestUtils.instance.isDebug?
@@ -57,7 +240,7 @@ module Scoutui::Base
57
240
 
58
241
  Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + "Process TYPE #{_val} into #{_xpath}" if Scoutui::Utils::TestUtils.instance.isDebug?
59
242
 
60
- obj = Scoutui::Base::QBrowser.getObject(my_driver, _xpath)
243
+ obj = Scoutui::Base::QBrowser.getObject(my_driver, _xpath, Scoutui::Commands::Utils.instance.getTimeout)
61
244
 
62
245
  if !obj.nil? && !obj.attribute('type').downcase.match(/(text|password|email)/).nil?
63
246
  Scoutui::Logger::LogMgr.instance.commands.info "send_keys(#{_val})"
@@ -139,6 +322,11 @@ module Scoutui::Base
139
322
  return
140
323
  end
141
324
 
325
+ if !e[STEP_KEY]['assertions'].is_a?(Array)
326
+ Scoutui::Logger::LogMgr.instance.warn __FILE__ + (__LINE__).to_s + " \'assertions\' field must be type Array."
327
+ return
328
+ end
329
+
142
330
  _req = Scoutui::Utils::TestUtils.instance.getReq()
143
331
 
144
332
  puts __FILE__ + (__LINE__).to_s + "======= #{e[STEP_KEY]['assertions']} ========="
@@ -161,15 +349,33 @@ module Scoutui::Base
161
349
  _v=a
162
350
 
163
351
 
164
- if _v.has_key?('locator')
352
+ if _v.has_key?('reqid')
353
+ _req = _v['reqid']
354
+
355
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Temp req #{_req} for assertion"
356
+ end
357
+
358
+
359
+ if _v.has_key?('locator') && _v['locator'].is_a?(String) && !_v.has_key?('visible_when')
360
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Process pageObject #{_v}"
361
+ isVisible=Scoutui::Base::Assertions.instance.isVisible(my_driver, _v['locator'], _req)
362
+ elsif _v.has_key?('locator')
165
363
  _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
364
 
168
- # _locator = Scoutui::Utils::TestUtils.instance.getPageElement(_v['locator'])
365
+ if !_locator.match(/^page\([\w\d]+\)/).nil?
366
+ _obj = processPageElement(my_driver, _k, _locator)
367
+ puts __FILE__ + (__LINE__).to_s + " Processed #{_locator} => #{_obj.class.to_s}"
368
+ else
369
+
370
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " " + _k.to_s + " => " + _locator
371
+
372
+ # _locator = Scoutui::Utils::TestUtils.instance.getPageElement(_v['locator'])
169
373
 
170
- _obj = Scoutui::Base::QBrowser.getFirstObject(my_driver, _locator, Scoutui::Commands::Utils.instance.getTimeout())
374
+ _obj = Scoutui::Base::QBrowser.getFirstObject(my_driver, _locator, Scoutui::Commands::Utils.instance.getTimeout())
375
+
376
+ Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " HIT #{_locator} => #{!_obj.nil?}" if Scoutui::Utils::TestUtils.instance.isDebug?
377
+ end
171
378
 
172
- Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " HIT #{_locator} => #{!_obj.nil?}" if Scoutui::Utils::TestUtils.instance.isDebug?
173
379
  end
174
380
 
175
381
  if _v.has_key?('visible_when')
@@ -177,9 +383,8 @@ module Scoutui::Base
177
383
  if _v['visible_when'].match(/always/i)
178
384
  Scoutui::Logger::LogMgr.instance.asserts.info __FILE__ + (__LINE__).to_s + " Verify assertion #{_k} - #{_locator} visible - #{!_obj.nil?.to_s}"
179
385
  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")
386
+ elsif Scoutui::Base::Assertions.instance.visible_when_never(_k, _v, _obj, _req)
387
+ ;
183
388
  elsif _v['visible_when'].match(/role\=/i)
184
389
  _role = _v['visible_when'].match(/role\=(.*)/i)[1].to_s
185
390
  _expected_role = Scoutui::Utils::TestUtils.instance.getRole()
@@ -192,6 +397,10 @@ module Scoutui::Base
192
397
  end
193
398
 
194
399
  end
400
+
401
+
402
+
403
+
195
404
  end
196
405
 
197
406
 
@@ -234,8 +443,31 @@ module Scoutui::Base
234
443
 
235
444
  Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + "\t\t#{link_name} => #{xpath}" if Scoutui::Utils::TestUtils.instance.isDebug?
236
445
 
446
+
447
+ # Check if the verification is a "windows.*" verification
448
+
449
+ if !xpath.match(/window[s]\.length\s*\(\d+\)/).nil?
450
+ _expected_length=xpath.match(/window[s]\.length\s*\((.*)\)/i)[1].to_s
451
+
452
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + "\tExpect window.length is #{_expected_length}"
453
+
454
+ if _expected_length =~ /\A\d+\z/
455
+ # 5150
456
+ totalWindows = my_driver.window_handles.length
457
+
458
+ if Scoutui::Utils::TestUtils.instance.assertExpected?
459
+ Testmgr::TestReport.instance.getReq(_req).get_child('window_size').add(totalWindows==_expected_length.to_i, "Verify number of windows is #{_expected_length} actual(#{totalWindows})")
460
+ end
461
+
462
+ end
463
+
464
+ next
465
+ end
466
+
467
+
237
468
  if !xpath.match(/\$\{.*\}/).nil?
238
- xpath = Scoutui::Base::UserVars.instance.get(xpath)
469
+ # xpath = Scoutui::Base::UserVars.instance.get(xpath)
470
+ xpath = Scoutui::Base::UserVars.instance.normalize(xpath)
239
471
  end
240
472
 
241
473
 
@@ -318,10 +550,18 @@ module Scoutui::Base
318
550
 
319
551
  if _v['visible_when'].match(/always/i)
320
552
  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")
553
+
554
+ if Scoutui::Utils::TestUtils.instance.assertExpected?
555
+ Testmgr::TestReport.instance.getReq(_req).get_child('visible_when').add(!_obj.nil?, "Verify #{_k} - #{_locator} visible")
556
+ end
557
+
322
558
  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")
559
+ Scoutui::Logger::LogMgr.instance.asserts.info "Verify #{_k} #{_locator} never visible - #{obj.nil?.to_s}"
560
+
561
+ if Scoutui::Utils::TestUtils.instance.assertExpected?
562
+ Testmgr::TestReport.instance.getReq(_req).get_child('visible_when').add(obj.nil?, "Verify #{_k} #{_locator} not visible")
563
+ end
564
+
325
565
  elsif _v['visible_when'].match(/role\=/i)
326
566
  _role = _v['visible_when'].match(/role\=(.*)/i)[1].to_s
327
567
  _expected_role = Scoutui::Utils::TestUtils.instance.getRole()
@@ -330,7 +570,11 @@ module Scoutui::Base
330
570
 
331
571
  if _role==_expected_role.to_s
332
572
  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}")
573
+
574
+ if Scoutui::Utils::TestUtils.instance.assertExpected?
575
+ Testmgr::TestReport.instance.getReq(_req).get_child('visible_when').add(!_obj.nil?, "Verify #{_k} #{_locator} visible when role #{_role}")
576
+ end
577
+
334
578
  end
335
579
 
336
580
  end
@@ -359,7 +603,7 @@ module Scoutui::Base
359
603
 
360
604
  # _locator = Scoutui::Utils::TestUtils.instance.getPageElement(_v['locator'])
361
605
 
362
- _obj = Scoutui::Base::QBrowser.getFirstObject(my_driver, _locator)
606
+ _obj = Scoutui::Base::QBrowser.getFirstObject(my_driver, _locator, Scoutui::Commands::Utils.instance.getTimeout())
363
607
 
364
608
  Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " HIT #{_locator} => #{!_obj.nil?}" if Scoutui::Utils::TestUtils.instance.isDebug?
365
609
  end
@@ -372,13 +616,16 @@ module Scoutui::Base
372
616
 
373
617
  end
374
618
 
375
- obj = Scoutui::Base::QBrowser.getFirstObject(my_driver, xpath)
619
+ obj = Scoutui::Base::QBrowser.getFirstObject(my_driver, xpath, Scoutui::Commands::Utils.instance.getTimeout())
376
620
 
377
621
  Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " obj : #{obj}"
378
622
 
379
623
  Scoutui::Logger::LogMgr.instance.asserts.info __FILE__ + (__LINE__).to_s + " Verify #{xpath} visible - #{obj.kind_of?(Selenium::WebDriver::Element).to_s}"
380
624
 
381
- Testmgr::TestReport.instance.getReq(_req).get_child('visible_when').add(!obj.nil?, __FILE__ + (__LINE__).to_s + " Verify #{xpath} visible")
625
+
626
+ if Scoutui::Utils::TestUtils.instance.assertExpected?
627
+ Testmgr::TestReport.instance.getReq(_req).get_child('visible_when').add(!obj.nil?, __FILE__ + (__LINE__).to_s + " Verify #{xpath} visible")
628
+ end
382
629
 
383
630
  if obj.nil?
384
631
  Scoutui::Logger::LogMgr.instance.warn " NOT FOUND : #{link_name} with xpath #{xpath}" if Scoutui::Utils::TestUtils.instance.isDebug?
@@ -410,7 +657,7 @@ module Scoutui::Base
410
657
  dut_dupes = YAML.load_stream File.read(datafile)
411
658
  valid_file=true
412
659
  rescue => ex
413
- Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Invalid file: #{datafile} - abort processing."
660
+ Scoutui::Logger::LogMgr.instance.fatal __FILE__ + (__LINE__).to_s + " Invalid file: #{datafile} - abort processing."
414
661
  Scoutui::Logger::LogMgr.instance.info ex.backtrace
415
662
  end
416
663
 
@@ -426,7 +673,7 @@ module Scoutui::Base
426
673
  i+=1
427
674
 
428
675
  Scoutui::Utils::TestUtils.instance.setReq('UI')
429
- Scoutui::Commands::Utils.instance.resetTimeout()
676
+ Scoutui::Commands::Utils.instance.resetTimeout(Scoutui::Utils::TestUtils.instance.getDefaultWait)
430
677
 
431
678
  _action = e[STEP_KEY]["action"]
432
679
  _name = e[STEP_KEY]["name"]
@@ -434,14 +681,12 @@ module Scoutui::Base
434
681
  _skip = e[STEP_KEY]["skip"]
435
682
  _region = e[STEP_KEY]["region"]
436
683
  _reqid = e[STEP_KEY]["reqid"]
684
+ _execute_when = e[STEP_KEY]["execute_when"]
437
685
 
438
686
  if e[STEP_KEY].has_key?("timeout")
439
687
  Scoutui::Commands::Utils.instance.setTimeout(e[STEP_KEY]["timeout"])
440
688
  end
441
689
 
442
-
443
-
444
-
445
690
  if Scoutui::Utils::TestUtils.instance.isDebug?
446
691
  Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " action: #{_action}"
447
692
  Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " name: #{_name}"
@@ -455,9 +700,42 @@ module Scoutui::Base
455
700
  Testmgr::TestReport.instance.getReq(_reqid)
456
701
  Scoutui::Utils::TestUtils.instance.setReq(_reqid)
457
702
  else
458
- puts __FILE__ + (__LINE__).to_s + " REQID was not provided"
703
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " REQID was not provided"
459
704
  end
460
705
 
706
+
707
+ if !_execute_when.nil? && !_execute_when.to_s.empty?
708
+
709
+ if _execute_when.is_a?(String) && _execute_when.match(/^\s*(existsalert|existsalert|exists\(alert\))/i)
710
+
711
+ # puts __FILE__ + (__LINE__).to_s + " DEBUG - pause"; gets;
712
+
713
+ if QBrowser.existsAlert?(my_driver)
714
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " Execution continues - alert IS present #{e[STEP_KEY]}"
715
+
716
+ # puts __FILE__ + (__LINE__).to_s + " DEBUG - pause2"; gets;
717
+
718
+
719
+ else
720
+ # puts __FILE__ + (__LINE__).to_s + " + Execution skipped - alert is NOT present";; gets()
721
+ next;
722
+ end
723
+
724
+
725
+ elsif _execute_when.is_a?(String)
726
+ _rc=Scoutui::Base::Assertions.instance.isVisible(my_driver, _execute_when, _reqid, true)
727
+
728
+ puts __FILE__ + (__LINE__).to_s + " EXECUTE_WHEN #{_rc}";
729
+
730
+ if !_rc
731
+ Scoutui::Logger::LogMgr.instance.info " Execute_When: true - skip #{e[STEP_KEY]}"
732
+ next
733
+ end
734
+ end
735
+
736
+ end
737
+
738
+
461
739
  skipIt = (!_skip.nil?) && (_skip.to_s.strip.downcase=='true')
462
740
  Scoutui::Logger::LogMgr.instance.info "\to skip : #{skipIt}" if Scoutui::Utils::TestUtils.instance.isDebug?
463
741
 
@@ -467,6 +745,8 @@ module Scoutui::Base
467
745
  end
468
746
 
469
747
 
748
+
749
+
470
750
  if !isRun(e).nil?
471
751
 
472
752
  Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " ========> RUN <================="
@@ -489,6 +769,10 @@ module Scoutui::Base
489
769
 
490
770
  begin
491
771
 
772
+ if _action.is_a?(String) && _action=='stop'
773
+ Scoutui::Logger::LogMgr.instance.info " STOP TEST"
774
+ break;
775
+ end
492
776
 
493
777
  _command = eyeScout.getStrategy().processCommand(_action, e)
494
778
 
@@ -550,7 +834,7 @@ module Scoutui::Base
550
834
  Scoutui::Logger::LogMgr.instance.info "\t\t#{link_name} => #{xpath}" if Scoutui::Utils::TestUtils.instance.isDebug?
551
835
 
552
836
 
553
- obj = QBrowser.getObject(my_driver, xpath)
837
+ obj = QBrowser.getObject(my_driver, xpath, Scoutui::Commands::Utils.instance.getTimeout)
554
838
  Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " [click]: link object => #{obj.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
555
839
  obj.click
556
840