scoutui 0.1.3 → 2.0.0

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.
@@ -1,267 +0,0 @@
1
-
2
- require 'singleton'
3
- require 'pp'
4
- require 'optparse'
5
-
6
-
7
- module Scoutui::Utils
8
-
9
-
10
- class TestUtils
11
- include Singleton
12
-
13
- attr_accessor :options
14
- attr_accessor :page_model
15
-
16
- def initialize
17
-
18
- @env_list={:accounts => 'SCOUTUI_ACCOUNTS', :browser => 'SCOUTUI_BROWSER', :applitools_api_key => 'APPLITOOLS_API_KEY'}
19
- @options={}
20
-
21
- [:accounts, :browser, :test_file, :host, :loc, :title, :viewport,
22
- :userid, :password, :json_config_file, :page_model, :test_config, :debug].each do |o|
23
- @options[o]=nil
24
- end
25
-
26
- @options[:enable_eyes]=false
27
- @options[:match_level]='layout'
28
- @options[:debug]=false
29
-
30
- @page_model=nil
31
-
32
- Scoutui::Base::UserVars.instance.set('eyes.viewport', '1024x768')
33
-
34
- end
35
-
36
- def loadPageModel()
37
- if !@options[:page_model].nil?
38
- _f = File.read(@options[:page_model].to_s)
39
- @page_model = JSON.parse(_f)
40
-
41
- puts __FILE__ + (__LINE__).to_s + " JSON-PageModel => #{@page_model}" if Scoutui::Utils::TestUtils.instance.isDebug?
42
- end
43
- end
44
-
45
-
46
- def getPageElement(s)
47
- hit=@page_model
48
-
49
- nodes = s.split(/\./)
50
-
51
- nodes.each { |elt|
52
- getter = elt.split(/\(/)[0]
53
- _obj = elt.match(/\((.*)\)/)[1]
54
-
55
- puts __FILE__ + (__LINE__).to_s + " getter : #{getter} obj: #{_obj}" if Scoutui::Utils::TestUtils.instance.isDebug?
56
-
57
- if getter.downcase=='page'
58
- puts __FILE__ + (__LINE__).to_s + " -- process page --" if Scoutui::Utils::TestUtils.instance.isDebug?
59
- hit=@page_model[_obj]
60
- elsif getter.downcase=='get'
61
- hit=hit[_obj]
62
- end
63
- puts __FILE__ + (__LINE__).to_s + " HIT => #{hit}" if Scoutui::Utils::TestUtils.instance.isDebug?
64
- }
65
-
66
- hit
67
-
68
- end
69
-
70
-
71
- def parseCommandLine()
72
-
73
- OptionParser.new do |opt|
74
- opt.on('-c', '--config TESTFILE') { |o|
75
- if !o.nil?
76
- @options[:json_config_file]=o
77
-
78
- jFile = File.read(@options[:json_config_file])
79
- @options[:test_config]=jsonData=JSON.parse(jFile)
80
- end
81
- }
82
- opt.on('--accounts [Account]') { |o| @options[:accounts] = o }
83
- opt.on('-b', '--browser [TYPE]', [:chrome, :firefox, :ie, :safari, :phantomjs], "Select browser (chrome, ie, firefox, safari)") { |o| @options[:browser] = o }
84
- opt.on('-d', '--debug', 'Enable debug') { |o| @options[:debug] = true }
85
- opt.on('-h', '--host HOST') { |o| @options[:host] = o }
86
- opt.on('-l', '--lang LOCAL') { |o| @options[:loc] = o }
87
- opt.on('-k', '--key EyesLicense') { |o| options[:license_file] = o }
88
- opt.on('-a', '--app AppName') { |o| @options[:app] = o }
89
- opt.on('--match [LEVEL]', [:layout2, :layout, :strict, :exact, :content], "Select match level (layout, strict, exact, content)") { |o| @options[:match_level] = o }
90
-
91
- opt.on('--pagemodel [PageModel]') { |o|
92
- @options[:page_model] = o
93
- loadPageModel()
94
- }
95
- opt.on('-t', '--title TITLE') { |o| @options[:title] = o }
96
-
97
- opt.on('-u', '--user USER_ID') { |o|
98
- @options[:userid] = o
99
- Scoutui::Base::UserVars.instance.setVar(:user, @options[:userid].to_s)
100
- }
101
- opt.on('-p', '--password PASSWORD') { |o| @options[:password] = o }
102
- opt.on('-e', '--eyes', "Toggle eyes") {
103
- @options[:enable_eyes]=true
104
- }
105
- opt.on('--viewport [resolution]') { |o| options[:viewport] = o }
106
- end.parse!
107
-
108
- if Scoutui::Utils::TestUtils.instance.isDebug?
109
- puts __FILE__ + (__LINE__).to_s + " " + @options.to_s
110
- puts "Test file => #{@options[:test_file]}"
111
- puts "Host => #{@options[:host]}"
112
- puts "Loc => #{@options[:loc]}"
113
- puts "Title => #{@options[:title]}"
114
- puts "Browser => #{@options[:browser]}"
115
- puts "UserID => #{@options[:userid]}"
116
- puts "Password => #{@options[:password]}"
117
- puts "Eyes => #{@options[:enable_eyes]}"
118
- puts "Test Cfg => #{@options[:json_config_file]}"
119
- puts "Match Level => #{@options[:match_level]}"
120
- puts "Accounts => #{@options[:accounts]}"
121
- puts "Viewport => #{@options[:viewport]}"
122
- puts "Viewport (Var) => #{Scoutui::Base::UserVars.instance.getViewPort().to_s}"
123
- puts "PageModel file => #{@options[:page_model].to_s}"
124
- end
125
-
126
- @options
127
- end
128
-
129
- def isDebug?
130
- @options[:debug]
131
- end
132
-
133
- def eyesEnabled?
134
- @options[:enable_eyes]
135
- end
136
-
137
- def getLicenseFile()
138
- @options[:license_file].to_s
139
- end
140
-
141
- def getBrowser()
142
- getBrowserType()
143
- end
144
- def getBrowserType()
145
- @options[:browser]
146
- end
147
-
148
- def hasTestConfig?
149
- !@options[:json_config_file].nil?
150
- end
151
-
152
- def testConfigFile()
153
- @options[:json_config_file]
154
- end
155
-
156
- # Returns JSON file contents/format
157
- def getTestSettings()
158
-
159
- [:accounts, :browser, :host, :userid, :password].each do |k|
160
-
161
- puts __FILE__ + (__LINE__).to_s + " opt[test_config].has_key(#{k.to_s}) => #{@options[:test_config].has_key?(k.to_s)}" if Scoutui::Utils::TestUtils.instance.isDebug?
162
-
163
- puts __FILE__ + (__LINE__).to_s + " options[#{k}] : #{@options[k].to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
164
- if @options.has_key?(k) && !@options[k].nil?
165
- Scoutui::Base::UserVars.instance.set(k, @options[k].to_s)
166
- elsif @options[:test_config].has_key?(k.to_s)
167
-
168
- puts __FILE__ + (__LINE__).to_s + " opts[#{k}].nil => #{@options[k].nil?}" if Scoutui::Utils::TestUtils.instance.isDebug?
169
- # Ensure commnand line takes precedence
170
- if !@options[k].nil?
171
- puts __FILE__ + (__LINE__).to_s + " opt[#{k.to_s} => #{@options[k].to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
172
- Scoutui::Base::UserVars.instance.set(k, @options[k].to_s)
173
- else
174
- Scoutui::Base::UserVars.instance.set(k, @options[:test_config][k.to_s].to_s)
175
- end
176
-
177
- elsif @env_list.has_key?(k)
178
- # If an ENV is available, use it.
179
- puts __FILE__ + (__LINE__).to_s + " #{k} => ENV(#{@env_list[k]}) = #{ENV[@env_list[k].to_s]}" if Scoutui::Utils::TestUtils.instance.isDebug?
180
- Scoutui::Base::UserVars.instance.set(k, ENV[@env_list[k].to_s])
181
- end
182
- end
183
-
184
- puts __FILE__ + (__LINE__).to_s + " test_config => #{@options[:test_config]}" if Scoutui::Utils::TestUtils.instance.isDebug?
185
-
186
-
187
- # Applitools Eyes settings
188
- if @options[:test_config].has_key?('eyes')
189
-
190
- ['match_level', 'title', 'app', 'viewport'].each do |k|
191
-
192
- _v=nil
193
-
194
- if @options[:test_config]['eyes'].has_key?(k)
195
- _v=@options[:test_config]['eyes'][k].to_s
196
- end
197
-
198
- if !@options[k.to_sym].nil?
199
- _v=@options[k.to_sym].to_s
200
- end
201
-
202
- if Scoutui::Utils::TestUtils.instance.isDebug?
203
- puts __FILE__ + (__LINE__).to_s + " #{k} => #{_v}"
204
- end
205
-
206
- Scoutui::Base::UserVars.instance.set('eyes.' + k, _v) if !_v.nil?
207
-
208
- end
209
- end
210
-
211
- @options[:test_config]
212
- end
213
-
214
-
215
- def getTestConfig()
216
- @options[:test_config]
217
- end
218
-
219
- def match_level()
220
- @options[:match_level]
221
- end
222
-
223
- def getUserId()
224
- @options[:userid]
225
- end
226
-
227
- def getUser()
228
- getUserId()
229
- end
230
-
231
- def getPassword()
232
- @options[:password]
233
- end
234
-
235
- def testFile()
236
- @options[:test_file]
237
- end
238
-
239
- def host()
240
- @options[:host]
241
- end
242
-
243
- def loc()
244
- @options[:loc]
245
- end
246
- def localization()
247
- loc()
248
- end
249
-
250
- def appName()
251
- @options[:app].to_s
252
- end
253
-
254
- def title()
255
- @options[:title]
256
- end
257
-
258
- end
259
-
260
-
261
-
262
-
263
-
264
-
265
-
266
-
267
- end
@@ -1,3 +0,0 @@
1
- module Scoutui
2
- VERSION = "0.1.3"
3
- end
data/lib/scoutui.rb DELETED
@@ -1,8 +0,0 @@
1
-
2
- module Scoutui
3
-
4
- ROOT_DIR = File.join(File.dirname(File.expand_path(__FILE__)), 'scoutui').freeze
5
-
6
- Dir["#{ROOT_DIR}/*.rb"].each { |f| require f }
7
- Dir["#{ROOT_DIR}/**/*.rb"].each { |f| require f }
8
- end
data/scoutui.gemspec DELETED
@@ -1,33 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'scoutui/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "scoutui"
8
- spec.version = Scoutui::VERSION
9
- spec.authors = ["Peter Kim"]
10
- spec.email = ["h20dragon@outlook.com"]
11
-
12
- spec.summary = %q{Simple yet powerful navigation and browser snapshot framework.}
13
- spec.description = %q{Leverage a navigation framework integrated with Applitool's Eyes for page/image capture capabilities - welcome to the world of Visual Testing!}
14
- spec.homepage = "https://github.com/h20dragon"
15
- spec.license = "MIT"
16
-
17
- # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
- # delete this section to allow pushing this gem to any host.
19
-
20
-
21
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
- spec.bindir = "exe"
23
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
- spec.require_paths = ["lib"]
25
-
26
- spec.add_development_dependency "bundler"
27
- spec.add_development_dependency "rake"
28
- spec.add_development_dependency "rspec"
29
- spec.add_development_dependency "eyes_selenium"
30
- spec.add_development_dependency "selenium-webdriver", ">= 2.47"
31
- spec.add_development_dependency "httparty"
32
- spec.add_development_dependency "json"
33
- end