scoutui 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,23 +26,32 @@ module Scoutui::Eyes
26
26
  puts __FILE__ + (__LINE__).to_s + " create(#{use_eyes})" if Scoutui::Utils::TestUtils.instance.isDebug?
27
27
  eyes=nil
28
28
 
29
+
29
30
  if use_eyes
31
+ license_key=nil
30
32
 
31
33
  licFile=Scoutui::Utils::TestUtils.instance.getLicenseFile()
32
34
 
33
- valid_json=false
34
- begin
35
- jFile = File.read(licFile)
36
- jLicense=jsonData=JSON.parse(jFile)
37
- valid_json=true
38
- rescue => ex
39
- ;
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
40
49
  end
41
50
 
42
51
 
43
- if valid_json
52
+ if !license_key.nil?
44
53
  eyes=Applitools::Eyes.new()
45
- eyes.api_key = jLicense['api_key'].to_s
54
+ eyes.api_key = license_key
46
55
  eyes.force_fullpage_screenshot = true
47
56
 
48
57
  match_level = Scoutui::Base::UserVars.instance.getVar('eyes.match_level')
@@ -50,6 +59,9 @@ module Scoutui::Eyes
50
59
  eyes.match_level = Applitools::Eyes::MATCH_LEVEL[match_level.to_sym]
51
60
  end
52
61
 
62
+ ## TBD - eyes.open()
63
+
64
+
53
65
  end
54
66
 
55
67
  # eyes
@@ -7,6 +7,7 @@ module Scoutui::Eyes
7
7
 
8
8
  attr_accessor :drv
9
9
  attr_accessor :eyes
10
+ attr_accessor :testResults
10
11
 
11
12
  def teardown()
12
13
  @drv.quit()
@@ -26,23 +27,43 @@ module Scoutui::Eyes
26
27
 
27
28
 
28
29
  def closeOut()
29
- eyes().close(false)
30
+ return if !Scoutui::Utils::TestUtils.instance.eyesEnabled?
31
+ @testResults = eyes().close(false)
30
32
  eyes().abort_if_not_closed if !eyes().nil?
31
33
  end
32
34
 
33
- def check_window(tag)
35
+ def check_window(tag, region=nil)
34
36
  puts __FILE__ + (__LINE__).to_s + " check_window(#{tag.to_s})" if Scoutui::Utils::TestUtils.instance.isDebug?
35
37
 
36
38
  return if !Scoutui::Utils::TestUtils.instance.eyesEnabled?
37
39
 
38
- eyes().check_window(tag.to_s)
40
+ if region.nil?
41
+ eyes().check_window(tag.to_s)
42
+ else
43
+ f = eyes().force_fullpage_screenshot
44
+ eyes().check_region(:xpath, region, tag)
45
+ eyes().force_fullpage_screenshot = f
46
+ end
47
+
48
+ end
49
+
50
+ def generateReport()
51
+ puts " TestReport => #{@testResults}"
52
+ end
53
+
54
+ def getResults()
55
+ @testResults
39
56
  end
40
57
 
41
58
  def initialize(browserType)
59
+ @testResults=nil
60
+
42
61
  browserType = Scoutui::Base::UserVars.instance.getBrowserType()
62
+ viewport_size = Scoutui::Base::UserVars.instance.getViewPort()
43
63
 
44
64
  if Scoutui::Utils::TestUtils.instance.isDebug?
45
65
  puts __FILE__ + (__LINE__).to_s + " setup() : #{browserType}"
66
+ puts __FILE__ + (__LINE__).to_s + " viewport => #{viewport_size}"
46
67
  puts __FILE__ + (__LINE__).to_s + " eyes cfg => #{@eyesRecord}"
47
68
  puts __FILE__ + (__LINE__).to_s + " title => " + Scoutui::Base::UserVars.instance.getVar('eyes.title')
48
69
  puts __FILE__ + (__LINE__).to_s + " app => " + Scoutui::Base::UserVars.instance.getVar('eyes.app')
@@ -55,12 +76,15 @@ module Scoutui::Eyes
55
76
 
56
77
  puts __FILE__ + (__LINE__).to_s + " eyes => #{eyes}" if Scoutui::Utils::TestUtils.instance.isDebug?
57
78
 
58
- @driver = @eyes.open(
59
- app_name: Scoutui::Base::UserVars.instance.getVar('eyes.app'), # @eyesRecord['app'],
60
- test_name: Scoutui::Base::UserVars.instance.getVar('eyes.title'), # @eyesRecord['title'],
61
- viewport_size: {width: 1024, height: 768},
62
- # viewport_size: {width: 800, height: 600},
63
- driver: @drv)
79
+ ## TBD - move the following into eye_scout ??
80
+ if Scoutui::Utils::TestUtils.instance.eyesEnabled?
81
+ @driver = @eyes.open(
82
+ app_name: Scoutui::Base::UserVars.instance.getVar('eyes.app'), # @eyesRecord['app'],
83
+ test_name: Scoutui::Base::UserVars.instance.getVar('eyes.title'), # @eyesRecord['title'],
84
+ viewport_size: viewport_size,
85
+ # viewport_size: {width: 800, height: 600},
86
+ driver: @drv)
87
+ end
64
88
 
65
89
  rescue => ex
66
90
  puts ex.backtrace
@@ -11,6 +11,7 @@ class Scoutui::Navigator
11
11
  attr_reader :test_name
12
12
  attr_reader :viewport_size
13
13
  attr_reader :driver
14
+ attr_reader :test_list
14
15
 
15
16
  def initialize(opts={})
16
17
 
@@ -11,21 +11,64 @@ module Scoutui::Utils
11
11
  include Singleton
12
12
 
13
13
  attr_accessor :options
14
+ attr_accessor :page_model
14
15
 
15
16
  def initialize
16
17
 
18
+ @env_list={:accounts => 'SCOUTUI_ACCOUNTS', :browser => 'SCOUTUI_BROWSER', :applitools_api_key => 'APPLITOOLS_API_KEY'}
17
19
  @options={}
18
20
 
19
- [:test_file, :host, :loc, :title, :browser, :userid, :password, :json_config_file, :test_config, :debug].each do |o|
20
- o=nil
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
21
24
  end
22
25
 
23
- @options[:enable_eyes]=true
24
- @options[:match_level]='strict'
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
+
25
68
  end
26
69
 
70
+
27
71
  def parseCommandLine()
28
- # @options = {}
29
72
 
30
73
  OptionParser.new do |opt|
31
74
  opt.on('-c', '--config TESTFILE') { |o|
@@ -36,30 +79,30 @@ module Scoutui::Utils
36
79
  @options[:test_config]=jsonData=JSON.parse(jFile)
37
80
  end
38
81
  }
39
- opt.on('-d', '--debug Bool') { |o| @options[:debug] = (o.to_s.downcase=='true')}
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 }
40
85
  opt.on('-h', '--host HOST') { |o| @options[:host] = o }
41
86
  opt.on('-l', '--lang LOCAL') { |o| @options[:loc] = o }
42
87
  opt.on('-k', '--key EyesLicense') { |o| options[:license_file] = o }
43
88
  opt.on('-a', '--app AppName') { |o| @options[:app] = o }
44
- opt.on('--match [TYPE]', [:layout2, :layout, :strict, :exact, :content], "Select match level (layout, strict, exact, content)") { |o| @options[:match_level] = 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
+ }
45
95
  opt.on('-t', '--title TITLE') { |o| @options[:title] = o }
46
- opt.on('-b', '--browser BROWSER') { |o| @options[:browser] = o }
96
+
47
97
  opt.on('-u', '--user USER_ID') { |o|
48
98
  @options[:userid] = o
49
99
  Scoutui::Base::UserVars.instance.setVar(:user, @options[:userid].to_s)
50
100
  }
51
101
  opt.on('-p', '--password PASSWORD') { |o| @options[:password] = o }
52
- opt.on('-e', '--eyes Boolean') { |o|
53
- @options[:enabled_eyes]=false
54
-
55
- if !o.nil?
56
- if !o.match(/true|1/i).nil?
57
- @options[:enable_eyes]=true
58
- end
59
-
60
- end
61
-
102
+ opt.on('-e', '--eyes', "Toggle eyes") {
103
+ @options[:enable_eyes]=true
62
104
  }
105
+ opt.on('--viewport [resolution]') { |o| options[:viewport] = o }
63
106
  end.parse!
64
107
 
65
108
  if Scoutui::Utils::TestUtils.instance.isDebug?
@@ -74,6 +117,10 @@ module Scoutui::Utils
74
117
  puts "Eyes => #{@options[:enable_eyes]}"
75
118
  puts "Test Cfg => #{@options[:json_config_file]}"
76
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}"
77
124
  end
78
125
 
79
126
  @options
@@ -109,11 +156,14 @@ module Scoutui::Utils
109
156
  # Returns JSON file contents/format
110
157
  def getTestSettings()
111
158
 
112
- [:browser, :host, :userid, :password].each do |k|
159
+ [:accounts, :browser, :host, :userid, :password].each do |k|
113
160
 
114
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?
115
162
 
116
- if @options[:test_config].has_key?(k.to_s)
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)
117
167
 
118
168
  puts __FILE__ + (__LINE__).to_s + " opts[#{k}].nil => #{@options[k].nil?}" if Scoutui::Utils::TestUtils.instance.isDebug?
119
169
  # Ensure commnand line takes precedence
@@ -124,34 +174,48 @@ module Scoutui::Utils
124
174
  Scoutui::Base::UserVars.instance.set(k, @options[:test_config][k.to_s].to_s)
125
175
  end
126
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])
127
181
  end
128
182
  end
129
183
 
130
184
  puts __FILE__ + (__LINE__).to_s + " test_config => #{@options[:test_config]}" if Scoutui::Utils::TestUtils.instance.isDebug?
131
185
 
132
- ['match_level', 'title', 'app'].each do |k|
133
186
 
134
- _v=nil
187
+ # Applitools Eyes settings
188
+ if @options[:test_config].has_key?('eyes')
135
189
 
136
- if @options[:test_config].has_key?('eyes')
137
- _v=@options[:test_config]['eyes'][k].to_s
138
- end
190
+ ['match_level', 'title', 'app', 'viewport'].each do |k|
139
191
 
140
- if !@options[k.to_sym].nil?
141
- _v=@options[k.to_sym].to_s
142
- end
192
+ _v=nil
143
193
 
144
- if Scoutui::Utils::TestUtils.instance.isDebug?
145
- puts __FILE__ + (__LINE__).to_s + " #{k} => #{_v}"
146
- end
194
+ if @options[:test_config]['eyes'].has_key?(k)
195
+ _v=@options[:test_config]['eyes'][k].to_s
196
+ end
147
197
 
148
- Scoutui::Base::UserVars.instance.set('eyes.' + k, _v)
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
149
205
 
206
+ Scoutui::Base::UserVars.instance.set('eyes.' + k, _v) if !_v.nil?
207
+
208
+ end
150
209
  end
151
210
 
152
211
  @options[:test_config]
153
212
  end
154
213
 
214
+
215
+ def getTestConfig()
216
+ @options[:test_config]
217
+ end
218
+
155
219
  def match_level()
156
220
  @options[:match_level]
157
221
  end
@@ -1,3 +1,3 @@
1
1
  module Scoutui
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scoutui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Kim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-02 00:00:00.000000000 Z
11
+ date: 2015-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -125,7 +125,18 @@ files:
125
125
  - README.md
126
126
  - Rakefile
127
127
  - bin/console
128
+ - bin/scoutui_driver.rb
128
129
  - bin/setup
130
+ - examples/ex1/commands.yml
131
+ - examples/ex1/test-example.sh
132
+ - examples/ex1/test.config.json
133
+ - examples/ex2/commands.yml
134
+ - examples/ex2/page_model.json
135
+ - examples/ex2/test-example.sh
136
+ - examples/ex2/test.config.json
137
+ - examples/ex6/commands.yml
138
+ - examples/ex6/ex1.config.json
139
+ - examples/ex6/test-example.sh
129
140
  - lib/scoutui.rb
130
141
  - lib/scoutui/base/q_accounts.rb
131
142
  - lib/scoutui/base/q_applitools.rb