scoutui 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d2ef38c35bbbe09544c803a347d22aa1658a61a
4
- data.tar.gz: 72dfd08d341d962507bb673abdf84496c6e12a9c
3
+ metadata.gz: 938077e990f3023a4aa9e4dafd7e8ae5bbc3dd3d
4
+ data.tar.gz: a5e065f72639d6f9776a82e821dfd9417868ea1e
5
5
  SHA512:
6
- metadata.gz: bac1f9302a505ef00f51698c87b611355b2d949520c88a4707b4960df9ccf8e0cdc12d64f0e103707852b45e031c5dbc5e49ac15103bf6033635ae8ede26fa98
7
- data.tar.gz: 277d5ccac8c5a80f01c8b7a1283502af3c370905ba657806c3a30bc498643e9ab9aac7b9a115d942a09fc20342501a41d9c0bd24d894a795d9ce1fb350be3896
6
+ metadata.gz: e0e95dc05d1f4544bdd6b50ef04e7d98c86edfe9e9ddf24e6e954a6613ceffe7a744bba48bfefbe8de49e95da93ba1de720275a89adec347612a690318090907
7
+ data.tar.gz: 765e55a3126b0782041d23fe47ea2d9e3708388f64f2b0c633f177c0a530d5d640d8d18d37d5f23989168013183eed7fc73cbb322effb47e5b89bc000699703e
@@ -0,0 +1,31 @@
1
+ require 'rubygems'
2
+ #require 'selenium-webdriver'
3
+
4
+ module Scoutui::Base
5
+
6
+ class AppModel
7
+
8
+ attr_accessor :drv
9
+ attr_accessor :pages
10
+
11
+ def initialize()
12
+ @drv=nil
13
+ @pages={}
14
+ end
15
+
16
+ def getPage(n)
17
+ @pages[n]
18
+ end
19
+
20
+ def addPage(n, p)
21
+ @pages[n]=p
22
+ end
23
+
24
+ def setup()
25
+ end
26
+
27
+ end
28
+
29
+
30
+
31
+ end
@@ -0,0 +1,48 @@
1
+
2
+ module Scoutui::Base
3
+
4
+ class QAccounts
5
+
6
+
7
+ attr_accessor :dut
8
+ attr_accessor :accounts
9
+
10
+ def initialize(f='/Users/pkim/working/nui-qa/apps/gat/data/accounts.yaml')
11
+ @accounts = YAML.load_stream File.read(f)
12
+ end
13
+
14
+ def _find(id, attr)
15
+ hit = accounts.find { |h| h['account']['loginid'] == id }
16
+ if !hit.nil?
17
+ id=hit['account'][attr]
18
+ end
19
+ id
20
+ end
21
+
22
+ def getUserRecord(u)
23
+ hit=nil
24
+
25
+ userid=getUserId(u)
26
+ if !userid.nil?
27
+ hit={'userid' => getUserId(u), 'password' => getPassword(u) }
28
+ end
29
+
30
+ hit
31
+ end
32
+
33
+ def getUserId(userid)
34
+ id=nil
35
+ hit = accounts.find { |h| h['account']['loginid'].to_s == userid.to_s }
36
+ if !hit.nil?
37
+ id=hit['account']['loginid']
38
+ end
39
+ id
40
+ end
41
+
42
+ def getPassword(u)
43
+ _find(u, 'password')
44
+ end
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,125 @@
1
+ require 'rubygems'
2
+ require 'eyes_selenium'
3
+ require 'httparty'
4
+
5
+
6
+ module Scoutui::Base
7
+
8
+ class QApplitools
9
+
10
+
11
+ attr_accessor :eyes
12
+
13
+ def initialize
14
+ @eyes=nil
15
+ end
16
+
17
+
18
+ def setup
19
+ @eyes = Applitools::Eyes.new
20
+ # This is your api key, make sure you use it in all your tests.
21
+ @eyes.api_key = "API_KEY"
22
+
23
+ # Get a selenium web driver object.
24
+ @driver = Selenium::WebDriver.for :chrome
25
+ #Eyes.log_handler = Logger.new(STDOUT)
26
+ end
27
+
28
+ # Called after every test method runs. Can be used to tear
29
+ # down fixtures information.
30
+
31
+ def teardown
32
+ @eyes.abort_if_not_closed
33
+ end
34
+
35
+ def report(results)
36
+ download_diffs(results, "VIEW_KEY", '/tmp/diff_images')
37
+ end
38
+
39
+ # Fake test
40
+ def xxxtestit
41
+ #@eyes.baseline_name='my_test_name'
42
+ wrapped_driver = @eyes.open(
43
+ app_name: 'Applitools website',
44
+ test_name: 'Example test',
45
+ viewport_size: {width: 900, height: 650},
46
+ driver: @driver)
47
+ wrapped_driver.get 'https://www.applitools.com'
48
+ # Visual validation point #1
49
+ @eyes.check_window('Main Page')
50
+
51
+ wrapped_driver.find_element(:css, ".features>a").click
52
+ # Visual validation point #2
53
+ @eyes.check_window('Features Page')
54
+ results = @eyes.close(false)
55
+
56
+ download_diffs(results, "VIEW_KEY", './diff_images')
57
+ print_results(results, "VIEW_KEY")
58
+ end
59
+
60
+ def print_results(results, view_key)
61
+ if results.is_passed
62
+ print "Your test was passed!\n"
63
+ elsif results.is_new
64
+ print "Created new baseline, this is a new test or/and new configuration!"
65
+ else
66
+ print "Your test was failed!\n"
67
+ print "#{results.mismatches} out of #{results.steps} steps failed \n"
68
+ print "Here are the failed steps:\n"
69
+ session_id = get_session_id(results.url)
70
+ diff_urls = get_diff_urls(session_id, view_key)
71
+ diff_urls.each do |index, diff_url|
72
+ print "Step #{index} --> #{diff_url} \n"
73
+ end
74
+ print "For more details please go to #{results.url} to review the differences! \n"
75
+ end
76
+ end
77
+
78
+ def download_diffs(results, view_key, destination)
79
+ session_id = get_session_id(results.url)
80
+ diff_urls = get_diff_urls(session_id, view_key)
81
+ download_images(diff_urls, destination)
82
+ end
83
+
84
+ def download_images(diff_urls, destination)
85
+ diff_urls.each do |index, url|
86
+ File.open("#{destination}/step_#{index}_diff.png", 'wb') do |file|
87
+ file.write HTTParty.get(url)
88
+ end
89
+ end
90
+ end
91
+
92
+ def get_diff_urls(session_id, view_key)
93
+ info = "https://eyes.applitools.com/api/sessions/#{session_id}/?ApiKey=#{view_key}&format=json"
94
+ diff_template = "https://eyes.applitools.com/api/sessions/#{session_id}/steps/%s/diff?ApiKey=#{view_key}"
95
+ diff_urls = Hash.new
96
+
97
+ puts __FILE__ + (__LINE__).to_s + " info => #{info}"
98
+ response = HTTParty.get(info)
99
+
100
+ begin
101
+ data = JSON.parse(response.body)
102
+ index = 1
103
+ data['actualOutput'].each do |elem|
104
+ if (elem['isMatching'] == false)
105
+ diff_urls[index] = diff_template % [index]
106
+ index+=1
107
+ end
108
+ end
109
+
110
+ diff_urls
111
+
112
+ rescue JSON::ParserError
113
+ ;
114
+ end
115
+
116
+ end
117
+
118
+ def get_session_id(url)
119
+ /sessions\/(?<session>\d+)/.match(url)[1]
120
+ end
121
+
122
+ end
123
+
124
+
125
+ end
@@ -0,0 +1,52 @@
1
+ require 'rubygems'
2
+ require 'eyes_selenium'
3
+ require 'selenium-webdriver'
4
+
5
+
6
+ module Scoutui::Base
7
+
8
+
9
+ class QBrowser
10
+
11
+ attr_accessor :driver
12
+
13
+ def initialize()
14
+ end
15
+
16
+ def self.wait_for_exist(drv, xpath, _timeout=30)
17
+ puts __FILE__ + (__LINE__).to_s + " wait_for_exist(#{xpath}"
18
+ rc=nil
19
+ begin
20
+ Selenium::WebDriver::Wait.new(timeout: _timeout).until { drv.find_element(:xpath => xpath) }
21
+ rc=drv.find_element(:xpath => xpath)
22
+ rescue => ex
23
+ ;
24
+ end
25
+ rc
26
+ end
27
+
28
+ def self.getObject(drv, xpath, _timeout=30)
29
+ rc=nil
30
+ begin
31
+ Selenium::WebDriver::Wait.new(timeout: _timeout).until { drv.find_element(:xpath => xpath).displayed? }
32
+ rc=drv.find_element(:xpath => xpath)
33
+ rescue => ex
34
+ ;
35
+ end
36
+ rc
37
+ end
38
+
39
+ def wait_for(seconds)
40
+ Selenium::WebDriver::Wait.new(timeout: seconds).until { yield }
41
+ end
42
+
43
+ def driver
44
+ @driver
45
+ end
46
+
47
+
48
+
49
+ end
50
+
51
+
52
+ end
@@ -0,0 +1,123 @@
1
+
2
+
3
+ module Scoutui::Base
4
+
5
+
6
+ class TestRunner
7
+ attr_reader :drv # Selenium Webdriver
8
+ attr_reader :eyes # Applitools::Eyes
9
+ attr_reader :driver # Applitools::Eyes Driver
10
+ attr_reader :context
11
+ attr_reader :test_settings # { host, localization, dut }
12
+ attr_reader :userRecord
13
+ attr_reader :eyesRecord # {'title' , 'app'}
14
+
15
+ def initialize(_context)
16
+
17
+ @test_settings=nil
18
+ @eyesRecord=nil
19
+
20
+ if Scoutui::Utils::TestUtils.instance.hasTestConfig?
21
+
22
+ puts __FILE__ + (__LINE__).to_s + " * test config json => " + Scoutui::Utils::TestUtils.instance.testConfigFile() if Scoutui::Utils::TestUtils.instance.isDebug?
23
+
24
+ @test_settings=Scoutui::Utils::TestUtils.instance.getTestSettings()
25
+
26
+ accounts = Scoutui::Base::QAccounts.new()
27
+ @userRecord = accounts.getUserRecord(@test_settings['user'])
28
+
29
+ @eyesRecord = @test_settings['eyes']
30
+
31
+ end
32
+
33
+ end
34
+
35
+
36
+
37
+ def hasSettings?
38
+ Scoutui::Utils::TestUtils.instance.hasTestConfig?
39
+ end
40
+
41
+ def dumpSettings()
42
+ puts __FILE__ + (__LINE__).to_s + " dumpSettings()"
43
+ puts '-' * 72
44
+ puts @test_settings
45
+
46
+ puts "UserRecord => #{@userRecord}"
47
+ puts "Eyes Record => #{@eyesRecord}"
48
+ puts "Host => #{@test_settings['host']}"
49
+ end
50
+
51
+ def teardown()
52
+ @drv.quit()
53
+ end
54
+
55
+ def setup()
56
+ browserType = Scoutui::Utils::TestUtils.instance.getBrowserType()
57
+ puts __FILE__ + (__LINE__).to_s + " setup() : #{browserType}"
58
+
59
+ begin
60
+ @drv=Selenium::WebDriver.for browserType.to_sym
61
+ @eyes=Scoutui::Eyes::EyeFactory.instance.create(true)
62
+ puts __FILE__ + (__LINE__).to_s + " eyes => #{eyes}"
63
+
64
+ @driver = @eyes.open(
65
+ app_name: @eyesRecord['app'],
66
+ test_name: @eyesRecord['title'],
67
+ viewport_size: {width: 1024, height: 768},
68
+ # viewport_size: {width: 800, height: 600},
69
+ driver: @drv)
70
+
71
+ rescue => ex
72
+ puts ex.backtrace
73
+ end
74
+ @drv
75
+ end
76
+
77
+
78
+
79
+ def goto(url)
80
+ @drv.navigate().to(url)
81
+ end
82
+
83
+ def snapPage(tag)
84
+ @eyes.check_window(tag) if Scoutui::Utils::TestUtils.instance.eyesEnabled?
85
+ end
86
+
87
+
88
+ def run()
89
+ puts __FILE__ + (__LINE__).to_s + " run()" if Scoutui::Utils::TestUtils.instance.isDebug?
90
+
91
+ my_driver=nil
92
+
93
+ begin
94
+
95
+ app = Scoutui::Base::AppModel.new()
96
+
97
+ setup() # Browser is created
98
+
99
+ # Navigate to the specified host
100
+ goto(Scoutui::Base::UserVars.instance.get(:host))
101
+
102
+ snapPage('Landing Page')
103
+
104
+ Scoutui::Base::VisualTestFramework.processFile(@drv, @eyes, @test_settings)
105
+
106
+ teardown()
107
+
108
+ rescue => ex
109
+ puts ex.backtrace
110
+ ensure
111
+ puts __FILE__ + (__LINE__ ).to_s + " Close Eyes"
112
+ eyes.close(false)
113
+ eyes.abort_if_not_closed if !eyes.nil?
114
+ end
115
+
116
+ end
117
+
118
+
119
+
120
+ end
121
+
122
+
123
+ end
@@ -0,0 +1,119 @@
1
+ require 'json'
2
+
3
+ module Scoutui::Base
4
+
5
+
6
+ class TestSettings
7
+
8
+ attr_accessor :bEyes
9
+ attr_accessor :browserType
10
+ attr_accessor :eut
11
+ attr_accessor :user
12
+ attr_accessor :eyesReport
13
+ attr_accessor :url
14
+ attr_accessor :localization
15
+
16
+
17
+ def initialize(opts)
18
+ @bEyes=false
19
+ @browserType=opts[:but] || :firefox
20
+ @eut=opts[:eut] || :qa
21
+ @lang=opts[:lang] || "en-us"
22
+ @user=opts[:user] || nil
23
+ @eyesReport=opts[:eyesReport] || nil
24
+ @url=opts[:url]||nil
25
+
26
+ @localization_test_data='/Users/pkim/working/nui-qa/apps/gat/tests/localization.json'
27
+ @localization_json = File.read(@localization_test_data)
28
+ @localizationObj = JSON.parse(@localization_json)
29
+ end
30
+
31
+ def setConfig(c)
32
+ if c.instance_of?(Hash)
33
+ @testConfig=c
34
+ else
35
+ # a JSON file was passed
36
+ jFile = File.read(c)
37
+ @testConfig=JSON.parse(jFile)
38
+ end
39
+
40
+ @testConfig
41
+ end
42
+
43
+
44
+ def getScout()
45
+ @testConfig["dut"]
46
+ end
47
+
48
+ def setLang(lang)
49
+ @lang=lang
50
+ end
51
+
52
+
53
+ def getLocalization()
54
+ # @testConfig["language-mapping"][@lang]
55
+ @localizationObj["language-mapping"][@lang]
56
+ end
57
+
58
+ def getUrl()
59
+ @url
60
+ end
61
+
62
+ def url
63
+ getUrl()
64
+ end
65
+
66
+ def setUrl(u)
67
+ @url=u
68
+ end
69
+
70
+ def getEyesReport()
71
+ @eyesReport
72
+ end
73
+
74
+ def getLanguage()
75
+ getLang()
76
+ end
77
+
78
+ def getUser()
79
+ @user
80
+ end
81
+
82
+ def getLang()
83
+ @lang
84
+ end
85
+
86
+ def getBUT()
87
+ @browserType
88
+ end
89
+
90
+ def setEUT(e)
91
+ @eut=e
92
+ end
93
+
94
+ def getEUT()
95
+ @eut
96
+ end
97
+
98
+ def browserType()
99
+ @browserType
100
+ end
101
+
102
+ def enableEyes(b=true)
103
+ @bEyes=b
104
+ end
105
+
106
+ def disableEyes()
107
+ @bEyes=false
108
+ end
109
+
110
+ def isEyes?
111
+ @bEyes
112
+ end
113
+
114
+ end
115
+
116
+
117
+ end
118
+
119
+
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'singleton'
3
+
4
+ module Scoutui::Base
5
+
6
+ class UserVars
7
+ include Singleton
8
+
9
+ attr_accessor :globals
10
+
11
+ def initialize
12
+ @globals={
13
+ :userid => nil,
14
+ :password => nil,
15
+ :host => nil,
16
+ :localization => 'en-us'
17
+ }
18
+ end
19
+
20
+ def getHost()
21
+ @globals[:host].to_s
22
+ end
23
+
24
+ def get(k)
25
+ v=k
26
+
27
+ if k=='${userid}'
28
+ k=:userid
29
+ elsif k=='${password}'
30
+ k=:password
31
+ elsif k=='${host}'
32
+ k=:host
33
+ end
34
+
35
+ if @globals.has_key?(k)
36
+ v=@globals[k]
37
+ end
38
+ v
39
+ end
40
+
41
+ def set(k, v)
42
+ setVar(k, v)
43
+ v
44
+ end
45
+
46
+ def setVar(k, v)
47
+ @globals[k]=v
48
+ v
49
+ end
50
+
51
+
52
+ end
53
+
54
+
55
+
56
+ end
@@ -0,0 +1,165 @@
1
+ require 'rubygems'
2
+
3
+ ##
4
+ # 1. q_applitools
5
+ # 2. q_accounts
6
+
7
+ module Scoutui::Base
8
+
9
+ class VisualTestFramework
10
+
11
+ def initialize()
12
+
13
+ end
14
+
15
+
16
+ def self.processExpected(my_driver, e)
17
+ puts "\to Expected: #{e['page']['expected'].class.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
18
+
19
+ if e['page'].has_key?('expected')
20
+ expected_list=e['page']['expected']
21
+
22
+ expected_list.each_pair do |link_name, xpath|
23
+ puts "\t\t#{link_name} => #{xpath}" if Scoutui::Utils::TestUtils.instance.isDebug?
24
+
25
+ obj = Scoutui::Base::QBrowser.getObject(my_driver, xpath)
26
+
27
+ if obj.nil?
28
+ puts " NOT FOUND : #{link_name} with xpath #{xpath}"
29
+ else
30
+ puts " link object(#{link_name} with xpath #{xpath}=> #{obj.displayed?}"
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+
37
+
38
+ def self.processCommand(_action, e, my_driver)
39
+ puts __FILE__ + (__LINE__).to_s + " Process ACTION : #{_action}" if Scoutui::Utils::TestUtils.instance.isDebug?
40
+
41
+ if !_action.match(/type\(/).nil?
42
+ _xpath = _action.match(/type\((.*),\s*/)[1].to_s
43
+ _val = _action.match(/type\(.*,\s*(.*)\)/)[1].to_s
44
+
45
+ puts __FILE__ + (__LINE__).to_s + "Process TYPE #{_val} into #{_xpath}" if Scoutui::Utils::TestUtils.instance.isDebug?
46
+
47
+ obj = Scoutui::Base::QBrowser.getObject(my_driver, _xpath)
48
+ if !obj.nil? && !obj.attribute('type').downcase.match(/(text|password)/).nil?
49
+ obj.send_keys(Scoutui::Base::UserVars.instance.get(_val))
50
+ end
51
+
52
+ end
53
+
54
+ if !_action.match(/click\(/).nil?
55
+ _xpath = _action.match(/click\s*\((.*)\)/)[1].to_s.strip
56
+ puts __FILE__ + (__LINE__).to_s + " click => #{_xpath}" if Scoutui::Utils::TestUtils.instance.isDebug?
57
+ obj = Scoutui::Base::QBrowser.getObject(my_driver, _xpath)
58
+ obj.click
59
+
60
+ processExpected(my_driver, e)
61
+ end
62
+
63
+ end
64
+
65
+
66
+ # Scoutui::Base::VisualTestFramework.processFile(@drv, @eyes, @test_settings['host'], @test_settings['dut'])
67
+ def self.processFile(my_driver, eyes, test_settings)
68
+
69
+ baseUrl = Scoutui::Base::UserVars.instance.getHost()
70
+ datafile = test_settings['dut']
71
+
72
+ puts __FILE__ + (__LINE__).to_s + " processFile(#{my_driver}, #{eyes}, #{baseUrl}, #{datafile})" if Scoutui::Utils::TestUtils.instance.isDebug?
73
+
74
+ i=0
75
+ dut_dupes = YAML.load_stream File.read(datafile)
76
+ dut_dupes.each do |e|
77
+ puts '-' * 72 if Scoutui::Utils::TestUtils.instance.isDebug?
78
+ puts "#{i.to_s}. Processing #{e.inspect}" if Scoutui::Utils::TestUtils.instance.isDebug?
79
+ i+=1
80
+
81
+ _action = e["page"]["action"]
82
+ _name = e["page"]["name"]
83
+ _url = e["page"]["url"]
84
+ _skip = e["page"]["skip"]
85
+
86
+ if Scoutui::Utils::TestUtils.instance.isDebug?
87
+ puts __FILE__ + (__LINE__).to_s + " action: #{_action}"
88
+ puts __FILE__ + (__LINE__).to_s + " name: #{_name}"
89
+ puts __FILE__ + (__LINE__).to_s + " url : #{_url}"
90
+ puts __FILE__ + (__LINE__).to_s + " skip: #{_skip}"
91
+ end
92
+
93
+ skipIt = (!_skip.nil?) && (_skip.to_s.strip.downcase=='true')
94
+ puts "\to skip : #{skipIt}" if Scoutui::Utils::TestUtils.instance.isDebug?
95
+
96
+ if skipIt
97
+ puts __FILE__ + (__LINE__).to_s + " SKIP - #{_name}" if Scoutui::Utils::TestUtils.instance.isDebug?
98
+ next
99
+ end
100
+
101
+ if !(_action.nil? || _action.empty?)
102
+ processCommand(_action, e, my_driver)
103
+ next
104
+ end
105
+
106
+ _relativeUrl = _url.strip.start_with?('/')
107
+
108
+ url = e["page"]["url"].to_s
109
+
110
+ if _relativeUrl
111
+ puts __FILE__ + (__LINE__).to_s + " [relative url]: #{baseUrl} with #{url}" if Scoutui::Utils::TestUtils.instance.isDebug?
112
+ url = baseUrl + url
113
+ end
114
+
115
+ name = e["page"]["name"].to_s
116
+ my_driver.navigate().to(url)
117
+
118
+
119
+ puts "\to Expected: #{e['page']['expected'].class.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
120
+
121
+ if e['page'].has_key?('expected')
122
+ expected_list=e['page']['expected']
123
+
124
+ expected_list.each_pair do |link_name, xpath|
125
+ puts "\t\t#{link_name} => #{xpath}" if Scoutui::Utils::TestUtils.instance.isDebug?
126
+
127
+ obj = Scoutui::Base::QBrowser.getObject(my_driver, xpath)
128
+
129
+ if obj.nil?
130
+ puts __FILE__ + (__LINE__).to_s + " NOT FOUND : #{link_name} with xpath #{xpath}"
131
+ else
132
+ puts __FILE__ + (__LINE__).to_s + " link object(#{link_name} with xpath #{xpath}=> #{obj.displayed?}" if Scoutui::Utils::TestUtils.instance.isDebug?
133
+ end
134
+
135
+ end
136
+ end
137
+
138
+ eyes.check_window(name) if Scoutui::Utils::TestUtils.instance.eyesEnabled?
139
+
140
+ puts "\to links : #{e['page']['links'].class.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
141
+
142
+ if e['page'].has_key?('links')
143
+ links=e['page']['links']
144
+
145
+ links.each_pair do |link_name, xpath|
146
+ puts "\t\t#{link_name} => #{xpath}" if Scoutui::Utils::TestUtils.instance.isDebug?
147
+
148
+
149
+ obj = QBrowser.getObject(my_driver, xpath)
150
+ puts __FILE__ + (__LINE__).to_s + " [click]: link object => #{obj.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
151
+ obj.click
152
+
153
+ eyes.check_window(link_name) if Scoutui::Utils::TestUtils.instance.eyesEnabled?
154
+ end
155
+ end
156
+
157
+ end
158
+
159
+
160
+ end
161
+
162
+ end
163
+
164
+
165
+ end
@@ -0,0 +1,23 @@
1
+ require_relative 'version'
2
+
3
+ require 'forwardable'
4
+
5
+ class Scoutui::Navigator
6
+ extend Forwardable
7
+
8
+ attr_reader :test_options
9
+
10
+ attr_reader :app_name
11
+ attr_reader :test_name
12
+ attr_reader :viewport_size
13
+ attr_reader :driver
14
+
15
+ def initialize(opts={})
16
+
17
+ end
18
+
19
+
20
+
21
+
22
+
23
+ end
@@ -0,0 +1,160 @@
1
+ require 'rubygems'
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
+
15
+ def initialize
16
+
17
+ @options={}
18
+
19
+ [:test_file, :host, :loc, :title, :browser, :userid, :password, :json_config_file, :test_config, :debug].each do |o|
20
+ o=nil
21
+ end
22
+
23
+ @options[:enable_eyes]=true
24
+ end
25
+
26
+ def parseCommandLine()
27
+ @options = {}
28
+ OptionParser.new do |opt|
29
+ opt.on('-f', '--file TESTFILE') { |o|
30
+ if !o.nil?
31
+ @options[:json_config_file]=o
32
+
33
+ jFile = File.read(@options[:json_config_file])
34
+ @options[:test_config]=jsonData=JSON.parse(jFile)
35
+ end
36
+ }
37
+ opt.on('-d', '--debug Bool') { |o| @options[:debug] = (o.to_s.downcase=='true')}
38
+ opt.on('-h', '--host HOST') { |o| @options[:host] = o }
39
+ opt.on('-l', '--lang LOCAL') { |o| @options[:loc] = o }
40
+ opt.on('-t', '--title TITLE') { |o| @options[:title] = o }
41
+ opt.on('-b', '--browser BROWSER') { |o| @options[:browser] = o }
42
+ opt.on('-u', '--user USER_ID') { |o|
43
+ @options[:userid] = o
44
+ Scoutui::Base::UserVars.instance.setVar(:user, @options[:userid].to_s)
45
+ }
46
+ opt.on('-p', '--password PASSWORD') { |o| @options[:password] = o }
47
+ opt.on('-e', '--eyes Boolean') { |o|
48
+ if !o.nil?
49
+ if !o.match(/true|1/i).nil?
50
+ @options[:enable_eyes]=true
51
+ end
52
+
53
+ end
54
+
55
+ }
56
+ end.parse!
57
+
58
+ puts __FILE__ + (__LINE__).to_s + " " + @options.to_s
59
+ puts "Test file => #{@options[:test_file]}"
60
+ puts "Host => #{@options[:host]}"
61
+ puts "Loc => #{@options[:loc]}"
62
+ puts "Title => #{@options[:title]}"
63
+ puts "Browser => #{@options[:browser]}"
64
+ puts "UserID => #{@options[:userid]}"
65
+ puts "Password => #{@options[:password]}"
66
+ puts "Eyes => #{@options[:enable_eyes]}"
67
+ puts "Test Cfg => #{@options[:json_config_file]}"
68
+
69
+ @options
70
+ end
71
+
72
+ def isDebug?
73
+ @options[:debug]
74
+ end
75
+
76
+ def eyesEnabled?
77
+ @options[:enable_eyes]
78
+ end
79
+
80
+ def getBrowser()
81
+ getBrowserType()
82
+ end
83
+ def getBrowserType()
84
+ @options[:browser]
85
+ end
86
+
87
+ def hasTestConfig?
88
+ !@options[:json_config_file].nil?
89
+ end
90
+
91
+ def testConfigFile()
92
+ @options[:json_config_file]
93
+ end
94
+
95
+ # Returns JSON file contents/format
96
+ def getTestSettings()
97
+
98
+ [:host, :userid, :password].each do |k|
99
+
100
+ puts __FILE__ + (__LINE__).to_s + " opt[test_config].has_key(#{k.to_s}) => #{@options[:test_config].has_key?(k.to_s)}"
101
+ if @options[:test_config].has_key?(k.to_s)
102
+
103
+ puts __FILE__ + (__LINE__).to_s + " opts[#{k}].nil => #{@options[k].nil?}"
104
+ # Ensure commnand line takes precedence
105
+ if !@options[k].nil?
106
+ puts __FILE__ + (__LINE__).to_s + " opt[#{k.to_s} => #{@options[k].to_s}"
107
+ Scoutui::Base::UserVars.instance.set(k, @options[k].to_s)
108
+ else
109
+
110
+ Scoutui::Base::UserVars.instance.set(k, @options[:test_config][k.to_s].to_s)
111
+ end
112
+
113
+ end
114
+ end
115
+
116
+ @options[:test_config]
117
+ end
118
+
119
+ def getUserId()
120
+ @options[:userid]
121
+ end
122
+
123
+ def getUser()
124
+ getUserId()
125
+ end
126
+
127
+ def getPassword()
128
+ @options[:password]
129
+ end
130
+
131
+ def testFile()
132
+ @options[:test_file]
133
+ end
134
+
135
+ def host()
136
+ @options[:host]
137
+ end
138
+
139
+ def loc()
140
+ @options[:loc]
141
+ end
142
+ def localization()
143
+ loc()
144
+ end
145
+
146
+
147
+ def title()
148
+ @options[:title]
149
+ end
150
+
151
+ end
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+ end
@@ -1,3 +1,3 @@
1
1
  module Scoutui
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
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.0
4
+ version: 0.1.1
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-09-29 00:00:00.000000000 Z
11
+ date: 2015-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -127,6 +127,16 @@ files:
127
127
  - bin/console
128
128
  - bin/setup
129
129
  - lib/scoutui.rb
130
+ - lib/scoutui/base/app_model.rb
131
+ - lib/scoutui/base/q_accounts.rb
132
+ - lib/scoutui/base/q_applitools.rb
133
+ - lib/scoutui/base/q_browser.rb
134
+ - lib/scoutui/base/test_runner.rb
135
+ - lib/scoutui/base/test_settings.rb
136
+ - lib/scoutui/base/user_vars.rb
137
+ - lib/scoutui/base/visual_test_framework.rb
138
+ - lib/scoutui/navigator.rb
139
+ - lib/scoutui/utils/utils.rb
130
140
  - lib/scoutui/version.rb
131
141
  - scoutui.gemspec
132
142
  homepage: https://github.com/h20dragon