scoutui 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +154 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/scoutui_driver.rb +22 -0
- data/bin/setup +7 -0
- data/examples/ex1/commands.holidays.yml +45 -0
- data/examples/ex1/commands.yml +25 -0
- data/examples/ex1/test-example.sh +38 -0
- data/examples/ex1/test.config.json +16 -0
- data/examples/ex2/commands.yml +35 -0
- data/examples/ex2/page_model.json +28 -0
- data/examples/ex2/test-example.sh +39 -0
- data/examples/ex2/test.config.json +25 -0
- data/lib/scoutui.rb +8 -0
- data/lib/scoutui/appmodel/q_model.rb +82 -0
- data/lib/scoutui/base/assertions.rb +62 -0
- data/lib/scoutui/base/q_accounts.rb +52 -0
- data/lib/scoutui/base/q_applitools.rb +127 -0
- data/lib/scoutui/base/q_browser.rb +185 -0
- data/lib/scoutui/base/q_form.rb +261 -0
- data/lib/scoutui/base/test_scout.rb +120 -0
- data/lib/scoutui/base/test_settings.rb +109 -0
- data/lib/scoutui/base/user_vars.rb +108 -0
- data/lib/scoutui/base/visual_test_framework.rb +574 -0
- data/lib/scoutui/commands/click_object.rb +45 -0
- data/lib/scoutui/commands/command.rb +56 -0
- data/lib/scoutui/commands/commands.rb +133 -0
- data/lib/scoutui/commands/exists_alert.rb +54 -0
- data/lib/scoutui/commands/fill_form.rb +56 -0
- data/lib/scoutui/commands/jsalert/action_jsalert.rb +58 -0
- data/lib/scoutui/commands/mouse_over.rb +31 -0
- data/lib/scoutui/commands/pause.rb +26 -0
- data/lib/scoutui/commands/select_object.rb +54 -0
- data/lib/scoutui/commands/strategy.rb +202 -0
- data/lib/scoutui/commands/submit_form.rb +44 -0
- data/lib/scoutui/commands/type.rb +44 -0
- data/lib/scoutui/commands/update_url.rb +45 -0
- data/lib/scoutui/commands/utils.rb +128 -0
- data/lib/scoutui/commands/verify_element.rb +198 -0
- data/lib/scoutui/commands/verify_form.rb +26 -0
- data/lib/scoutui/eyes/eye_factory.rb +76 -0
- data/lib/scoutui/eyes/eye_scout.rb +239 -0
- data/lib/scoutui/logger/log_mgr.rb +105 -0
- data/lib/scoutui/navigator.rb +24 -0
- data/lib/scoutui/utils/utils.rb +352 -0
- data/lib/scoutui/version.rb +3 -0
- data/scoutui.gemspec +35 -0
- metadata +54 -2
- data/pkg/scoutui-2.0.0.gem +0 -0
@@ -0,0 +1,198 @@
|
|
1
|
+
require_relative './commands'
|
2
|
+
|
3
|
+
module Scoutui::Commands
|
4
|
+
|
5
|
+
class VerifyElement < Command
|
6
|
+
|
7
|
+
def _verify(elt)
|
8
|
+
begin
|
9
|
+
|
10
|
+
Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " VerifyElement._verify(#{elt})"
|
11
|
+
|
12
|
+
_k = elt.keys[0].to_s
|
13
|
+
a = elt[_k]
|
14
|
+
|
15
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Assert => #{_k} : #{a.to_s}"
|
16
|
+
|
17
|
+
# _k = 'generic-assertion'
|
18
|
+
_v={}
|
19
|
+
|
20
|
+
if a.is_a?(Hash)
|
21
|
+
_v=a
|
22
|
+
|
23
|
+
_req = Scoutui::Utils::TestUtils.instance.getReq()
|
24
|
+
|
25
|
+
if _v.has_key?('locator')
|
26
|
+
_locator = _v['locator'].to_s
|
27
|
+
Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " " + _k.to_s + " => " + _locator
|
28
|
+
|
29
|
+
# _locator = Scoutui::Utils::TestUtils.instance.getPageElement(_v['locator'])
|
30
|
+
|
31
|
+
_obj = Scoutui::Base::QBrowser.getFirstObject(@drv, _locator, Scoutui::Commands::Utils.instance.getTimeout())
|
32
|
+
|
33
|
+
Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " HIT #{_locator} => #{!_obj.nil?}"
|
34
|
+
end
|
35
|
+
|
36
|
+
if _v.has_key?('visible_when')
|
37
|
+
|
38
|
+
if _v['visible_when'].match(/always/i)
|
39
|
+
Scoutui::Logger::LogMgr.instance.asserts.info __FILE__ + (__LINE__).to_s + " Verify assertion #{_k} - #{_locator} visible - #{!_obj.nil?.to_s}"
|
40
|
+
Testmgr::TestReport.instance.getReq(_req).get_child('visible_when').add(!_obj.nil?, "Verify assertion #{_k} - #{_locator} visible")
|
41
|
+
elsif _v['visible_when'].match(/never/i)
|
42
|
+
Scoutui::Logger::LogMgr.instance.asserts.info "Verify assertion #{_k} #{_locator} not visible - #{obj.nil?.to_s}"
|
43
|
+
Testmgr::TestReport.instance.getReq(_req).get_child('visible_when').add(obj.nil?, "Verify assertion #{_k} #{_locator} not visible")
|
44
|
+
elsif _v['visible_when'].match(/role\=/i)
|
45
|
+
_role = _v['visible_when'].match(/role\=(.*)/i)[1].to_s
|
46
|
+
_expected_role = Scoutui::Utils::TestUtils.instance.getRole()
|
47
|
+
|
48
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " Verify assertion object exists if the role #{_role} matches expected role #{_expected_role.to_s}"
|
49
|
+
|
50
|
+
if _role==_expected_role.to_s
|
51
|
+
Scoutui::Logger::LogMgr.instance.asserts.info "Verify assertion #{_k} #{_locator} visible when role #{_role} - #{!_obj.nil?.to_s}"
|
52
|
+
Testmgr::TestReport.instance.getReq(_req).get_child('visible_when').add(!_obj.nil?, "Verify assertion #{_k} #{_locator} visible when role #{_role}")
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
rescue => ex
|
62
|
+
|
63
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " abort processing."
|
64
|
+
Scoutui::Logger::LogMgr.instance.debug "Error during processing: #{ex}"
|
65
|
+
puts __FILE__ + (__LINE__).to_s + "\nBacktrace:\n\t#{ex.backtrace.join("\n\t")}"
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
def execute(drv)
|
72
|
+
@drv=drv if !drv.nil?
|
73
|
+
_e=getLocator()
|
74
|
+
|
75
|
+
if _e.nil?
|
76
|
+
_e = @cmd.match(/(verifyelt|verifyelement)\s*\((.*)\)/)[2].to_s.strip
|
77
|
+
end
|
78
|
+
|
79
|
+
Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " verifyElement => #{_e}" if Scoutui::Utils::TestUtils.instance.isDebug?
|
80
|
+
|
81
|
+
_xpath = Scoutui::Base::UserVars.instance.get(_e)
|
82
|
+
|
83
|
+
Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " | translate : #{_xpath}" if Scoutui::Utils::TestUtils.instance.isDebug?
|
84
|
+
|
85
|
+
|
86
|
+
page_elt = Scoutui::Utils::TestUtils.instance.getPageElement(_xpath)
|
87
|
+
|
88
|
+
Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " Process page request #{page_elt} => #{page_elt.class.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
|
89
|
+
|
90
|
+
xpath=nil
|
91
|
+
|
92
|
+
if page_elt.is_a?(Hash) && page_elt.has_key?('locator')
|
93
|
+
|
94
|
+
locator = Scoutui::Base::UserVars.instance.get(page_elt['locator'].to_s)
|
95
|
+
|
96
|
+
|
97
|
+
if page_elt.has_key?('visible_when') && page_elt['visible_when'].match(/title\(/)
|
98
|
+
current_title = @drv.title
|
99
|
+
expected_title = Regexp.new(page_elt['visible_when'].match(/title\((.*)\)/)[1].to_s)
|
100
|
+
rc=!expected_title.match(current_title).nil?
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " Verify expected title (#{current_title}) matches (#{expected_title}) => " + rc.to_s
|
105
|
+
|
106
|
+
# Testmgr::TestReport.instance.getReq('UI').tc('visible_when').add(expected_title==current_title, "Verify title matches #{expected_title}")
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
if page_elt.has_key?('visible_when') && page_elt['visible_when'].match(/(text|value)\s*\(/)
|
111
|
+
|
112
|
+
rc=nil
|
113
|
+
|
114
|
+
|
115
|
+
condition = page_elt['visible_when'].match(/(value|text)\((.*)\)/)[1].to_s
|
116
|
+
tmpObj = page_elt['visible_when'].match(/(value|text)\((.*)\)/)[2].to_s
|
117
|
+
expectedVal = page_elt['visible_when'].match(/(value|text)\s*\(.*\)\s*\=\s*(.*)/)[2].to_s
|
118
|
+
Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " tmpObj => #{tmpObj} with expected value #{expectedVal}"
|
119
|
+
|
120
|
+
xpath = Scoutui::Base::UserVars.instance.get(tmpObj)
|
121
|
+
|
122
|
+
obj = Scoutui::Base::QBrowser.getObject(@drv, xpath)
|
123
|
+
|
124
|
+
if !obj.nil?
|
125
|
+
# Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " value : #{obj.value.to_s}"
|
126
|
+
Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " text : #{obj.text.to_s}"
|
127
|
+
|
128
|
+
if obj.tag_name.downcase.match(/(select)/)
|
129
|
+
_opt = Selenium::WebDriver::Support::Select.new(obj)
|
130
|
+
opts = _opt.selected_options
|
131
|
+
Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " selected => #{opts.to_s}"
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
opts.each do |o|
|
136
|
+
Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + "| <v, t>::<#{o.attribute('value').to_s}, #{o.text.to_s}>"
|
137
|
+
|
138
|
+
desc=nil
|
139
|
+
|
140
|
+
|
141
|
+
if condition=='text' && o.text==expectedVal
|
142
|
+
desc=" Verify #{locator} is visible since condition (#{condition} #{xpath} is met."
|
143
|
+
elsif condition=='value' && o.attribute('value').to_s==expectedVal
|
144
|
+
desc=" Verify #{locator} is visible since #{condition} of #{xpath} is #{expectedVal}"
|
145
|
+
end
|
146
|
+
|
147
|
+
if !desc.nil?
|
148
|
+
locatorObj = Scoutui::Base::QBrowser.getObject(@drv, locator)
|
149
|
+
|
150
|
+
Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " LocatorObj : #{locatorObj} : #{!locatorObj.nil? && locatorObj.displayed?}"
|
151
|
+
|
152
|
+
|
153
|
+
Testmgr::TestReport.instance.getReq('UI').tc('visible_when').add(!locatorObj.nil? && locatorObj.displayed?, desc)
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " value : #{obj.attribute('value').to_s}"
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
elsif page_elt.is_a?(Hash)
|
171
|
+
|
172
|
+
page_elt.each do |elt|
|
173
|
+
|
174
|
+
puts __FILE__ + (__LINE__).to_s + " ELT => #{elt} : #{elt.to_s}"
|
175
|
+
puts __FILE__ + (__LINE__).to_s + " ELT[0] : #{elt[0]}"
|
176
|
+
puts __FILE__ + (__LINE__).to_s + " ELT[1] : #{elt[1]}"
|
177
|
+
|
178
|
+
if elt.is_a?(Array)
|
179
|
+
_h={ elt[0] => elt[1] }
|
180
|
+
|
181
|
+
_verify(_h)
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
185
|
+
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " xpath : #{xpath}"
|
190
|
+
|
191
|
+
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
require_relative './commands'
|
3
|
+
|
4
|
+
module Scoutui::Commands
|
5
|
+
|
6
|
+
|
7
|
+
class VerifyForm < Command
|
8
|
+
|
9
|
+
|
10
|
+
def execute(drv)
|
11
|
+
@drv=drv if !drv.nil?
|
12
|
+
|
13
|
+
_form = @cmd.match(/verifyform\((.*)\s*\)/)[1].to_s
|
14
|
+
|
15
|
+
Scoutui::Logger::LogMgr.instance.debug __FILE__ + (__LINE__).to_s + " VerifyForm.execute : #{_form}"
|
16
|
+
|
17
|
+
_f = Scoutui::Utils::TestUtils.instance.getForm(_form)
|
18
|
+
_f.dump()
|
19
|
+
_f.verifyForm(@drv)
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
|
2
|
+
require 'singleton'
|
3
|
+
|
4
|
+
|
5
|
+
module Scoutui::Eyes
|
6
|
+
|
7
|
+
|
8
|
+
class EyeFactory
|
9
|
+
include Singleton
|
10
|
+
|
11
|
+
attr_accessor :eyesList
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@eyesList=Array.new()
|
15
|
+
end
|
16
|
+
|
17
|
+
def createScout()
|
18
|
+
browserType = Scoutui::Base::UserVars.instance.getBrowserType()
|
19
|
+
eyeScout = EyeScout.new(browserType)
|
20
|
+
end
|
21
|
+
|
22
|
+
def createEyes()
|
23
|
+
|
24
|
+
use_eyes = Scoutui::Utils::TestUtils.instance.eyesEnabled?
|
25
|
+
|
26
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " create(#{use_eyes})" if Scoutui::Utils::TestUtils.instance.isDebug?
|
27
|
+
eyes=nil
|
28
|
+
|
29
|
+
|
30
|
+
if use_eyes
|
31
|
+
license_key=nil
|
32
|
+
|
33
|
+
licFile=Scoutui::Utils::TestUtils.instance.getLicenseFile()
|
34
|
+
|
35
|
+
if !licFile.empty?
|
36
|
+
|
37
|
+
valid_json=false
|
38
|
+
begin
|
39
|
+
jFile = File.read(licFile)
|
40
|
+
jLicense=jsonData=JSON.parse(jFile)
|
41
|
+
license_key=jLicense['api_key'].to_s
|
42
|
+
valid_json=true
|
43
|
+
rescue => ex
|
44
|
+
;
|
45
|
+
end
|
46
|
+
|
47
|
+
elsif ENV.has_key?('APPLITOOLS_API_KEY')
|
48
|
+
license_key=ENV['APPLITOOLS_API_KEY'].to_s
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
if !license_key.nil?
|
53
|
+
eyes=Applitools::Eyes.new()
|
54
|
+
eyes.api_key = license_key
|
55
|
+
eyes.force_fullpage_screenshot = true
|
56
|
+
|
57
|
+
match_level = Scoutui::Base::UserVars.instance.getVar('eyes.match_level')
|
58
|
+
|
59
|
+
eyes.match_level = Applitools::Eyes::MATCH_LEVEL[match_level.to_sym]
|
60
|
+
end
|
61
|
+
|
62
|
+
## TBD - eyes.open()
|
63
|
+
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
# eyes
|
68
|
+
@eyesList << eyes
|
69
|
+
@eyesList.last()
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,239 @@
|
|
1
|
+
require 'eyes_selenium'
|
2
|
+
require 'testmgr'
|
3
|
+
|
4
|
+
module Scoutui::Eyes
|
5
|
+
|
6
|
+
|
7
|
+
class EyeScout
|
8
|
+
|
9
|
+
attr_accessor :eyes
|
10
|
+
attr_accessor :testResults
|
11
|
+
attr_accessor :strategy
|
12
|
+
|
13
|
+
def teardown()
|
14
|
+
@strategy.quit()
|
15
|
+
end
|
16
|
+
|
17
|
+
def navigate(url)
|
18
|
+
@strategy.navigate(url)
|
19
|
+
end
|
20
|
+
|
21
|
+
def drv()
|
22
|
+
@strategy.getDriver()
|
23
|
+
end
|
24
|
+
|
25
|
+
def getStrategy()
|
26
|
+
@strategy
|
27
|
+
end
|
28
|
+
|
29
|
+
def eyes()
|
30
|
+
@eyes
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
#---- 5150 -----
|
35
|
+
def get_session_id(url)
|
36
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " -- get_session_id(#{url}) =="
|
37
|
+
_s=/sessions\/(?<session>\d+)/.match(url)[1]
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_diff_urls(session_id, view_key)
|
42
|
+
info = "https://eyes.applitools.com/api/sessions/#{session_id}/?ApiKey=#{view_key}&format=json"
|
43
|
+
diff_template = "https://eyes.applitools.com/api/sessions/#{session_id}/steps/%s/diff?ApiKey=#{view_key}"
|
44
|
+
diff_urls = Hash.new
|
45
|
+
|
46
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " info => #{info}"
|
47
|
+
response = HTTParty.get(info)
|
48
|
+
|
49
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " RESP => #{response.to_s}"
|
50
|
+
|
51
|
+
begin
|
52
|
+
data = JSON.parse(response.body)
|
53
|
+
index = 1
|
54
|
+
data['actualOutput'].each do |elem|
|
55
|
+
if !elem.nil? && (elem['isMatching'] == false)
|
56
|
+
#diff_urls[index] = diff_template % [index]
|
57
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " #{index.to_s} :#{elem['tag'].to_s}"
|
58
|
+
#diff_urls[index] = diff_template % [index]
|
59
|
+
diff_urls[index] = { :tag => elem['tag'].to_s, :url => diff_template % [index] }
|
60
|
+
index+=1
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
diff_urls
|
65
|
+
|
66
|
+
rescue JSON::ParserError
|
67
|
+
;
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
def sanitize_filename(filename)
|
73
|
+
# Split the name when finding a period which is preceded by some
|
74
|
+
# character, and is followed by some character other than a period,
|
75
|
+
# if there is no following period that is followed by something
|
76
|
+
# other than a period
|
77
|
+
fn = filename.split /(?<=.)\.(?=[^.])(?!.*\.[^.])/m
|
78
|
+
|
79
|
+
# We now have one or two parts (depending on whether we could find
|
80
|
+
# a suitable period). For each of these parts, replace any unwanted
|
81
|
+
# sequence of characters with an underscore
|
82
|
+
fn.map! { |s| s.gsub /[^a-z0-9\-]+/i, '_' }
|
83
|
+
|
84
|
+
# Finally, join the parts with a period and return the result
|
85
|
+
return fn.join '.'
|
86
|
+
end
|
87
|
+
|
88
|
+
def download_images(diff_urls, destination)
|
89
|
+
diff_urls.each do |index, elem|
|
90
|
+
save_name = sanitize_filename(elem[:tag]) + ".step_#{index}_diff.png"
|
91
|
+
File.open("#{destination}/#{save_name}", 'wb') do |file|
|
92
|
+
file.write HTTParty.get(elem[:url])
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def saveDiffs(_eyes, results, outdir, view_key)
|
98
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " saveDiffs(#{outdir.to_s})"
|
99
|
+
|
100
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " | steps : #{results.steps.to_s}"
|
101
|
+
session_id = get_session_id(results.url)
|
102
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " session => #{session_id}"
|
103
|
+
|
104
|
+
diffs = get_diff_urls(session_id, view_key)
|
105
|
+
|
106
|
+
diffs.each do |d|
|
107
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " #{d.to_s}"
|
108
|
+
end
|
109
|
+
|
110
|
+
download_images(diffs, outdir)
|
111
|
+
|
112
|
+
end
|
113
|
+
#---- END 5150
|
114
|
+
|
115
|
+
|
116
|
+
def closeOut()
|
117
|
+
|
118
|
+
# Scoutui::Base::QHarMgr.instance.stop('/tmp/scoutui.har')
|
119
|
+
|
120
|
+
return if !Scoutui::Utils::TestUtils.instance.eyesEnabled?
|
121
|
+
@testResults = eyes().close(false)
|
122
|
+
|
123
|
+
Testmgr::TestReport.instance.getReq("EYES").testcase('Images').add(@testResults.steps.to_i > 0, "Verify at least 1 shot taken (#{@testResults.steps.to_s} shots)")
|
124
|
+
Testmgr::TestReport.instance.getReq("EYES").testcase('Images').add(@testResults.missing.to_i==0, "Verify Eyes did not miss any screens (#{@testResults.missing.to_s} screens)")
|
125
|
+
|
126
|
+
# 5150
|
127
|
+
_diffdir=Scoutui::Utils::TestUtils.instance.getDiffDir()
|
128
|
+
if ENV.has_key?('APPLITOOLS_VIEW_KEY') && !_diffdir.nil?
|
129
|
+
|
130
|
+
if Dir.exists?(_diffdir)
|
131
|
+
saveDiffs(eyes(), @testResults, _diffdir, ENV['APPLITOOLS_VIEW_KEY'])
|
132
|
+
else
|
133
|
+
Scoutui::Logger::LogMgr.instance.warn " Specified Visual Diff folder does not exist - #{_diffdir.to_s}. Unable to download diffs"
|
134
|
+
end
|
135
|
+
|
136
|
+
else
|
137
|
+
Scoutui::Logger::LogMgr.instance.info " Unable to download diff images - APPLITOOLS_VIEW_KEY not defined"
|
138
|
+
end
|
139
|
+
|
140
|
+
|
141
|
+
eyes().abort_if_not_closed if !eyes().nil?
|
142
|
+
end
|
143
|
+
|
144
|
+
def check_window(tag, region=nil)
|
145
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " check_window(#{tag.to_s})" if Scoutui::Utils::TestUtils.instance.isDebug?
|
146
|
+
|
147
|
+
return if !Scoutui::Utils::TestUtils.instance.eyesEnabled?
|
148
|
+
|
149
|
+
if region.nil?
|
150
|
+
eyes().check_window(tag.to_s)
|
151
|
+
else
|
152
|
+
f = eyes().force_fullpage_screenshot
|
153
|
+
eyes().check_region(:xpath, region, tag)
|
154
|
+
eyes().force_fullpage_screenshot = f
|
155
|
+
end
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
def generateReport()
|
160
|
+
|
161
|
+
if Scoutui::Utils::TestUtils.instance.eyesEnabled?
|
162
|
+
Scoutui::Logger::LogMgr.instance.debug " testResults.methods = #{@testResults.methods.sort.to_s}"
|
163
|
+
Scoutui::Logger::LogMgr.instance.info " Eyes.TestResults.Missing : #{@testResults.missing.to_s}"
|
164
|
+
Scoutui::Logger::LogMgr.instance.info " Eyes.TestResults.Matches : #{@testResults.matches.to_s}"
|
165
|
+
Scoutui::Logger::LogMgr.instance.info " Eyes.TestResults.Mismatches : #{@testResults.mismatches.to_s}"
|
166
|
+
Scoutui::Logger::LogMgr.instance.info " Eyes.TestResults.Passed : #{@testResults.passed?.to_s}"
|
167
|
+
Scoutui::Logger::LogMgr.instance.info " Eyes.TestResults.Steps : #{@testResults.steps.to_s}"
|
168
|
+
end
|
169
|
+
|
170
|
+
Scoutui::Logger::LogMgr.instance.info " TestReport => #{@testResults}"
|
171
|
+
# Testmgr::TestReport.instance.generateReport()
|
172
|
+
Testmgr::TestReport.instance.report()
|
173
|
+
end
|
174
|
+
|
175
|
+
def getResults()
|
176
|
+
@testResults
|
177
|
+
end
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
def initialize(browserType)
|
182
|
+
@testResults=nil
|
183
|
+
|
184
|
+
browserType = Scoutui::Base::UserVars.instance.getBrowserType()
|
185
|
+
viewport_size = Scoutui::Base::UserVars.instance.getViewPort()
|
186
|
+
|
187
|
+
Testmgr::TestReport.instance.setDescription('ScoutUI Test')
|
188
|
+
Testmgr::TestReport.instance.setEnvironment(:qa, Scoutui::Utils::TestUtils.instance.getHost())
|
189
|
+
Testmgr::TestReport.instance.addRequirement('UI')
|
190
|
+
Testmgr::TestReport.instance.getReq('UI').add(Testmgr::TestCase.new('visible_when', "visible_when"))
|
191
|
+
Testmgr::TestReport.instance.addRequirement('Command')
|
192
|
+
Testmgr::TestReport.instance.getReq('Command').add(Testmgr::TestCase.new('isValid', "isValid"))
|
193
|
+
|
194
|
+
Testmgr::TestReport.instance.getReq('UI').add(Testmgr::TestCase.new('expectJsAlert', 'expectJsAlert'))
|
195
|
+
|
196
|
+
if Scoutui::Utils::TestUtils.instance.isDebug?
|
197
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " setup() : #{browserType}"
|
198
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " sauce => " + Scoutui::Utils::TestUtils.instance.eyesEnabled?.to_s
|
199
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " viewport => #{viewport_size}"
|
200
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " eyes cfg => #{@eyesRecord}"
|
201
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " title => " + Scoutui::Base::UserVars.instance.getVar('eyes.title')
|
202
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " app => " + Scoutui::Base::UserVars.instance.getVar('eyes.app')
|
203
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " match_level => " + Scoutui::Base::UserVars.instance.getVar('eyes.match_level')
|
204
|
+
end
|
205
|
+
|
206
|
+
begin
|
207
|
+
|
208
|
+
# Scoutui::Base::QHarMgr.instance.start()
|
209
|
+
# @profile.proxy = Scoutui::Base::QHarMgr.instance.getSeleniumProfile()
|
210
|
+
|
211
|
+
@strategy = Scoutui::Commands::Strategy.new()
|
212
|
+
|
213
|
+
@eyes=Scoutui::Eyes::EyeFactory.instance.createEyes()
|
214
|
+
|
215
|
+
Scoutui::Logger::LogMgr.instance.info __FILE__ + (__LINE__).to_s + " eyes => #{eyes}" if Scoutui::Utils::TestUtils.instance.isDebug?
|
216
|
+
|
217
|
+
## TBD - move the following into eye_scout ??
|
218
|
+
if Scoutui::Utils::TestUtils.instance.eyesEnabled?
|
219
|
+
@driver = @eyes.open(
|
220
|
+
app_name: Scoutui::Base::UserVars.instance.getVar('eyes.app'), # @eyesRecord['app'],
|
221
|
+
test_name: Scoutui::Base::UserVars.instance.getVar('eyes.title'), # @eyesRecord['title'],
|
222
|
+
viewport_size: viewport_size,
|
223
|
+
# viewport_size: {width: 800, height: 600},
|
224
|
+
driver: @strategy.getDriver())
|
225
|
+
end
|
226
|
+
|
227
|
+
rescue => ex
|
228
|
+
Scoutui::Logger::LogMgr.instance.info ex.backtrace
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
232
|
+
|
233
|
+
|
234
|
+
end
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
end
|