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,54 @@
1
+ # Ref
2
+ # http://stackoverflow.com/questions/15164742/combining-implicit-wait-and-explicit-wait-together-results-in-unexpected-wait-ti#answer-15174978
3
+ # http://selenium.googlecode.com/svn-history/r15117/trunk/docs/api/rb/Selenium/WebDriver/Support/Select.html#selected_options-instance_method
4
+
5
+ module Scoutui::Commands
6
+
7
+ class SelectObject < Command
8
+
9
+ def execute(drv)
10
+ @drv=drv if !drv.nil?
11
+
12
+ _req = Scoutui::Utils::TestUtils.instance.getReq()
13
+ obj=nil
14
+ _rc=false
15
+
16
+ begin
17
+
18
+ if !@cmd.match(/select\(/).nil?
19
+
20
+ _xpath = @cmd.match(/select\((.*),\s*/)[1].to_s
21
+ _val = @cmd.match(/select\(.*,\s*(.*)\)/)[1].to_s
22
+
23
+
24
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + "Process SELECT #{_val} into #{_xpath}" if Scoutui::Utils::TestUtils.instance.isDebug?
25
+
26
+ obj = Scoutui::Base::QBrowser.getObject(@drv, _xpath)
27
+
28
+ if !obj.nil? && obj.tag_name.downcase.match(/(select)/)
29
+
30
+ _opt = Selenium::WebDriver::Support::Select.new(obj)
31
+ _opt.select_by(:text, Scoutui::Base::UserVars.instance.get(_val))
32
+
33
+ _rc=true
34
+
35
+ # obj.send_keys(Scoutui::Base::UserVars.instance.get(_val))
36
+ else
37
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " Unable to process command SELECT => #{obj.to_s}"
38
+ end
39
+ end
40
+
41
+ rescue
42
+ ;
43
+ end
44
+
45
+ Testmgr::TestReport.instance.getReq(_req).testcase('select').add(!obj.nil?, "Verify object to select exists #{_xpath} : #{obj.class.to_s}")
46
+ Testmgr::TestReport.instance.getReq(_req).testcase('select').add(_rc, "Verify selected text #{_val}")
47
+ setResult(_rc)
48
+
49
+ end
50
+
51
+ end
52
+
53
+
54
+ end
@@ -0,0 +1,202 @@
1
+ require 'testmgr'
2
+
3
+
4
+ module Scoutui::Commands
5
+
6
+ class Strategy
7
+
8
+ attr_accessor :drv
9
+ attr_accessor :profile
10
+
11
+ def getDriver()
12
+ @drv
13
+ end
14
+
15
+ def loadModel(f)
16
+ rc=true
17
+ begin
18
+ rc=Scoutui::Utils::TestUtils.instance.loadModel(f)
19
+ rescue => ex
20
+ rc=false
21
+ end
22
+
23
+ rc
24
+ end
25
+
26
+ def navigate(url)
27
+ rc = false
28
+ begin
29
+ processCommand('navigate(' + url + ')', nil)
30
+ rc=true
31
+ rescue => ex
32
+ Scoutui::Logger::LogMgr.instance.warn "Error during processing: #{$!}"
33
+ Scoutui::Logger::LogMgr.instance.warn "Backtrace:\n\t#{e.backtrace.join("\n\t")}"
34
+ end
35
+
36
+ rc
37
+ end
38
+
39
+ def report()
40
+ Testmgr::TestReport.instance.report()
41
+ end
42
+
43
+ def quit()
44
+ @drv.quit()
45
+ end
46
+
47
+ def processCommands(cmds)
48
+ Scoutui::Commands::processCommands(cmds, getDriver())
49
+ end
50
+
51
+ def processCommand(_action, e=nil)
52
+ Scoutui::Commands::processCommand(_action, e, getDriver())
53
+ end
54
+
55
+ def setup(dut)
56
+ caps = Selenium::WebDriver::Remote::Capabilities.send(dut[:browserName])
57
+ caps.version = dut[:version]
58
+ caps.platform = dut[:platform]
59
+ caps[:name] = dut[:full_description]
60
+ caps
61
+ end
62
+
63
+ def initialize()
64
+
65
+ @profile=nil
66
+ browserType = Scoutui::Base::UserVars.instance.getBrowserType()
67
+
68
+ if false
69
+ if !browserType.to_s.match(/chrome/i).nil?
70
+ @profile = Selenium::WebDriver::Chrome::Profile.new
71
+ elsif !browserType.to_s.match(/fire/i).nil?
72
+ @profile = Selenium::WebDriver::Firefox::Profile.new
73
+ elsif !browserType.to_s.match(/ie/i).nil?
74
+ @profile = Selenium::WebDriver::IE::Profile.new
75
+ elsif !browserType.to_s.match(/safari/i).nil?
76
+ @profile = Selenium::WebDriver::Safari::Profile.new
77
+ else
78
+ @profile = Selenium::WebDriver::Firefox::Profile.new
79
+ browserType='firefox'
80
+ end
81
+
82
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " profile => #{@profile}"
83
+ end
84
+
85
+ if Scoutui::Utils::TestUtils.instance.sauceEnabled?
86
+
87
+ caps = Scoutui::Utils::TestUtils.instance.getCapabilities()
88
+ client=nil
89
+ proxy=nil
90
+
91
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " Capabilities => #{caps.to_s}"
92
+
93
+ if caps.nil?
94
+
95
+ caps = {
96
+ :platform => "Mac OS X 10.9",
97
+ :browserName => "chrome",
98
+ :version => "31",
99
+ :full_description => 'Rover Test'
100
+ }
101
+
102
+ elsif caps.has_key?(:platform) && caps[:platform].match(/os x/i)
103
+ tmpCaps = caps
104
+
105
+ if caps.has_key?(:deviceName) && caps[:deviceName].match(/iphone/i)
106
+ caps = Selenium::WebDriver::Remote::Capabilities.iphone()
107
+ elsif caps.has_key?(:browser) && caps[:browser].match(/chrome/i)
108
+ caps = Selenium::WebDriver::Remote::Capabilities.chrome()
109
+ elsif caps.has_key?(:browser) && caps[:browser].match(/firefox/i)
110
+ caps = Selenium::WebDriver::Remote::Capabilities.firefox()
111
+ elsif caps.has_key?(:browser) && caps[:browser].match(/safari/i)
112
+ caps = Selenium::WebDriver::Remote::Capabilities.safari()
113
+ end
114
+
115
+ tmpCaps.each_pair do |k, v|
116
+ caps[k.to_s]=v
117
+ end
118
+
119
+
120
+ elsif caps.has_key?(:platform) && caps[:platform].match(/windows/i)
121
+ tmpCaps = caps
122
+
123
+ if caps.has_key?(:browser) && caps[:browser].match(/edge/i)
124
+ caps = Selenium::WebDriver::Remote::Capabilities.edge()
125
+ elsif caps.has_key?(:browser) && caps[:browser].match(/chrome/i)
126
+ caps = Selenium::WebDriver::Remote::Capabilities.chrome()
127
+ elsif caps.has_key?(:browser) && caps[:browser].match(/firefox/i)
128
+ caps = Selenium::WebDriver::Remote::Capabilities.firefox()
129
+ else
130
+ caps = Selenium::WebDriver::Remote::Capabilities.internet_explorer()
131
+ end
132
+
133
+ tmpCaps.each_pair do |k, v|
134
+ caps[k.to_s]=v
135
+ end
136
+
137
+ elsif caps.has_key?(:deviceName) && caps[:deviceName].match(/(iphone|ipad)/i) && !caps[:deviceName].match(/simulator/i)
138
+ caps = Selenium::WebDriver::Remote::Capabilities.iphone()
139
+ caps['platform'] = 'OS X 10.10'
140
+ caps['version'] = '9.1'
141
+ caps['deviceName'] = 'iPhone 6 Plus'
142
+ caps['deviceOrientation'] = 'portrait'
143
+
144
+ if caps['deviceName'].match(/iphone/i)
145
+ client = Selenium::WebDriver::Remote::Http::Default.new
146
+ client.timeout = 360 # seconds – default is 60
147
+ end
148
+
149
+ elsif caps.has_key?(:deviceName) && caps[:deviceName].match(/(iphone|ipad)/i) && caps[:deviceName].match(/simulator/i)
150
+
151
+ proxyVal = "localhost:8080"
152
+
153
+ proxy = Selenium::WebDriver::Proxy.new(
154
+ :http => proxyVal,
155
+ :ftp => proxyVal,
156
+ :ssl => proxyVal
157
+ )
158
+
159
+ tmpCaps = caps
160
+
161
+ caps = Selenium::WebDriver::Remote::Capabilities.iphone(:proxy => proxy)
162
+
163
+ tmpCaps.each_pair do |k, v|
164
+ caps[k.to_s]=v
165
+ end
166
+
167
+ client = Selenium::WebDriver::Remote::Http::Default.new
168
+ client.timeout = 360 # seconds – default is 60
169
+
170
+ end
171
+
172
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " Capabilities => #{caps.to_s}"
173
+
174
+ sauce_endpoint = "http://#{ENV['SAUCE_USERNAME']}:#{ENV['SAUCE_ACCESS_KEY']}@ondemand.saucelabs.com:80/wd/hub"
175
+
176
+ caps[:name]=Scoutui::Utils::TestUtils.instance.getSauceName()
177
+ caps[:tags]=["Concur QE", "ScoutUI"]
178
+
179
+ begin
180
+ if client.nil?
181
+ @drv=Selenium::WebDriver.for :remote, :url => sauce_endpoint, :desired_capabilities => caps # setup(caps)
182
+ else
183
+ @drv=Selenium::WebDriver.for :remote, :url => sauce_endpoint, :http_client => client, :desired_capabilities => caps # setup(caps)
184
+ end
185
+
186
+ rescue => e
187
+ Scoutui::Logger::LogMgr.instance.debug "Error during processing: #{$!}"
188
+ Scoutui::Logger::LogMgr.instance.debug "Backtrace:\n\t#{ex.backtrace.join("\n\t")}"
189
+ end
190
+
191
+
192
+ else
193
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " Create WebDriver: #{browserType.to_s}"
194
+ @drv=Selenium::WebDriver.for browserType.to_sym, :profile => @profile
195
+ end
196
+
197
+ end
198
+
199
+ end
200
+
201
+
202
+ end
@@ -0,0 +1,44 @@
1
+
2
+
3
+ module Scoutui::Commands
4
+
5
+ class SubmitForm < Command
6
+
7
+ attr_accessor :form_name
8
+
9
+ def initialize(_cmd, _drv=nil)
10
+ super(_cmd, _drv)
11
+ @form_name = @cmd.match(/submitform\((.*)\s*\)/i)[1].to_s
12
+ end
13
+
14
+ def execute(drv=nil)
15
+ _req = Scoutui::Utils::TestUtils.instance.getReq()
16
+
17
+ Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " Process SubmitForm #{@form_name}" if Scoutui::Utils::TestUtils.instance.isDebug?
18
+
19
+ _rc=false
20
+
21
+ begin
22
+ @drv=drv if !drv.nil?
23
+
24
+ obj = Scoutui::Utils::TestUtils.instance.getForm(@form_name)
25
+ if !obj.nil?
26
+ obj.submitForm(@drv)
27
+ _rc=true
28
+ end
29
+
30
+ rescue
31
+ ;
32
+ end
33
+
34
+ Testmgr::TestReport.instance.getReq(_req).get_child('submitform').add(_rc, "Verify form submitted.")
35
+
36
+ setResult(_rc)
37
+ end
38
+
39
+
40
+ end
41
+
42
+
43
+
44
+ end
@@ -0,0 +1,44 @@
1
+
2
+
3
+ module Scoutui::Commands
4
+
5
+ class Type < Command
6
+
7
+
8
+ def execute(drv=nil)
9
+ @drv=drv if !drv.nil?
10
+
11
+ _rc=false
12
+ _req = Scoutui::Utils::TestUtils.instance.getReq()
13
+
14
+ begin
15
+ _xpath = @cmd.match(/type\((.*),\s*/)[1].to_s
16
+ _val = @cmd.match(/type\(.*,\s*(.*)\)/)[1].to_s
17
+
18
+ Scoutui::Logger::LogMgr.instance.commands.debug __FILE__ + (__LINE__).to_s + "Process TYPE #{_val} into #{_xpath}" if Scoutui::Utils::TestUtils.instance.isDebug?
19
+
20
+ obj = Scoutui::Base::QBrowser.getObject(@drv, _xpath)
21
+
22
+ if !obj.nil? && !obj.attribute('type').downcase.match(/(text|password|email)/).nil?
23
+ obj.send_keys(Scoutui::Base::UserVars.instance.get(_val))
24
+ _rc=true
25
+ else
26
+ Scoutui::Logger::LogMgr.instance.commands.debug __FILE__ + (__LINE__).to_s + " Unable to process command TYPE => #{obj.to_s}"
27
+ end
28
+
29
+ rescue
30
+ ;
31
+ end
32
+
33
+ Testmgr::TestReport.instance.getReq(_req).testcase('type').add(!obj.nil?, "Verify object #{_xpath} to type #{_val} exists : #{obj.class.to_s}")
34
+ Testmgr::TestReport.instance.getReq(_req).testcase('type').add(_rc, "Verify typed data #{_rc}")
35
+ setResult(_rc)
36
+
37
+ end
38
+
39
+
40
+ end
41
+
42
+
43
+
44
+ end
@@ -0,0 +1,45 @@
1
+ module Scoutui::Commands
2
+
3
+ class UpdateUrl < Command
4
+
5
+
6
+ def execute(drv)
7
+ @drv=drv if !drv.nil?
8
+
9
+ _req = Scoutui::Utils::TestUtils.instance.getReq()
10
+
11
+ baseUrl = Scoutui::Base::UserVars.instance.getHost()
12
+
13
+ url = @cmd.match(/navigate\s*\((.*)\)/)[1].to_s.strip
14
+ Scoutui::Logger::LogMgr.instance.commands.debug __FILE__ + (__LINE__).to_s + " url => #{url}" if Scoutui::Utils::TestUtils.instance.isDebug?
15
+
16
+ _relativeUrl = url.strip.start_with?('/')
17
+
18
+
19
+ if _relativeUrl
20
+ Scoutui::Logger::LogMgr.instance.commands.debug __FILE__ + (__LINE__).to_s + " [relative url]: #{baseUrl} with #{url}" if Scoutui::Utils::TestUtils.instance.isDebug?
21
+ url = baseUrl + url
22
+ end
23
+
24
+ url = Scoutui::Base::UserVars.instance.get(url)
25
+
26
+ Scoutui::Logger::LogMgr.instance.commands.debug __FILE__ + (__LINE__).to_s + " | translate : #{url}" if Scoutui::Utils::TestUtils.instance.isDebug?
27
+
28
+ _rc=false
29
+ begin
30
+ @drv.navigate.to(url)
31
+ _rc=true
32
+ rescue
33
+ ;
34
+ end
35
+
36
+
37
+ setResult(_rc)
38
+
39
+ end
40
+
41
+ end
42
+
43
+
44
+
45
+ end
@@ -0,0 +1,128 @@
1
+
2
+ require 'singleton'
3
+
4
+ module Scoutui::Commands
5
+
6
+
7
+ class Utils
8
+ include Singleton
9
+
10
+ attr_accessor :totalCommands
11
+ attr_accessor :timeout
12
+
13
+ def initialize
14
+ @command_list=['pause',
15
+ 'existsAlert',
16
+ 'fillform',
17
+ 'submitform',
18
+ 'type',
19
+ 'click',
20
+ 'mouseover',
21
+ 'navigate',
22
+ 'select',
23
+ 'verifyelt',
24
+ 'verifyelement',
25
+ 'verifyform']
26
+ @totalCommands={}
27
+ @timeout=30
28
+ @command_list.each do |c|
29
+ @totalCommands[c]=0
30
+ end
31
+ end
32
+
33
+ def resetTimeout()
34
+ setTimeout(30)
35
+ end
36
+
37
+ def setTimeout(_t)
38
+ @timeout=_t
39
+ end
40
+ def getTimeout()
41
+ @timeout
42
+ end
43
+
44
+ def isExistsAlert?(_action)
45
+ !_action.match(/(exist[s]*_*alert|existAlert|existsAlert|existsJsAlert|existsJsConfirm|existsJsPrompt)\(/i).nil?
46
+ end
47
+
48
+ def isVerifyElt?(_action)
49
+ !_action.match(/(verifyelt|verifyelement)\(/i).nil?
50
+ end
51
+
52
+ def isClick?(_action)
53
+ !_action.match(/click\(/i).nil?
54
+ end
55
+
56
+ def isGetAlert?(_action)
57
+ !_action.match(/(get_*alert|clickjsconfirm|clickjsprompt|clickjsalert)/i).nil?
58
+ end
59
+
60
+ def isFillForm?(_action)
61
+ !_action.match(/fillform\(/i).nil?
62
+ end
63
+
64
+ def isMouseOver?(_action)
65
+ !_action.match(/mouseover\(/).nil?
66
+ end
67
+
68
+ def isType?(_action)
69
+ !_action.match(/type\(/).nil?
70
+ end
71
+
72
+ def isSubmitForm?(_action)
73
+ !_action.match(/submitform\(/).nil?
74
+ end
75
+
76
+ def isVerifyForm?(_action)
77
+ !_action.match(/verifyform\(/).nil?
78
+ end
79
+
80
+ def isPause?(_action)
81
+ !_action.match(/pause/).nil?
82
+ end
83
+
84
+ def isSelect?(_action)
85
+ !_action.nil? && _action.match(/select/i)
86
+ end
87
+
88
+ def isNavigate?(_action)
89
+ !_action.nil? && _action.match(/(navigate|url)\(/i)
90
+ end
91
+
92
+ def isValid?(cmd)
93
+
94
+ rc=true
95
+
96
+ if isPause?(cmd)
97
+ @totalCommands['pause']+=1
98
+ elsif isExistsAlert?(cmd)
99
+ @totalCommands['existsAlert']+=1
100
+ elsif isVerifyElt?(cmd)
101
+ @totalCommands['verifyelt']+=1
102
+ elsif isVerifyForm?(cmd)
103
+ @totalCommands['verifyform']+=1
104
+ elsif isFillForm?(cmd)
105
+ @totalCommands['fillform']+=1
106
+ elsif isSubmitForm?(cmd)
107
+ @totalCommands['submitform']+=1
108
+ elsif isType?(cmd)
109
+ @totalCommands['type']+=1
110
+ elsif isClick?(cmd)
111
+ @totalCommands['click']+=1
112
+ elsif isMouseOver?(cmd)
113
+ @totalCommands['mouseover']+=1
114
+ elsif isSelect?(cmd)
115
+ @totalCommands['select']+=1
116
+ elsif isNavigate?(cmd)
117
+ @totalCommands['navigate']+=1
118
+ else
119
+ rc=false
120
+ end
121
+
122
+ rc
123
+ end
124
+
125
+ end
126
+
127
+
128
+ end