scoutui 0.1.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,36 +0,0 @@
1
- #/bin/bash
2
- ##
3
- # Description
4
- # This test script overrides the provided title and appname (if provided in the test config. file)
5
- #
6
- # Set the APPLITOOLS_API_KEY environment variable with your key.
7
- #
8
- # export APPLITOOLS_API_KEY="__YOUR_KEY_HERE__"
9
- ##
10
- SCOUTUI_BIN=../../bin/scoutui_driver.rb
11
- # Specify browser under test (chrome, firefox, ie, safari)
12
- BUT=chrome
13
-
14
- # Specify the title and appName needed by Applitools
15
- TITLE=DEMO-ONE
16
- APP=Elvis
17
-
18
- # Specify the test configuration file
19
- TEST_CFG="./ex6.config.json"
20
-
21
- ##
22
- # content
23
- # strict
24
- # exact
25
- # layyout
26
- ##
27
- MATCH_TYPE="layout"
28
-
29
- #EYES=--eyes
30
- EYES=""
31
-
32
- # The following command line parameters will override provided title and appName (if provided in test config file)
33
- $SCOUTUI_BIN --debug --config $TEST_CFG --browser $BUT $EYES --app $APP --title $TITLE --match $MATCH_TYPE --pagemodel ./page_model.json
34
-
35
- # The following
36
- # $SCOUTUI_BIN --config $TEST_CFG --eyes --match $MATCH_TYPE --browser $BUT
@@ -1,52 +0,0 @@
1
-
2
- module Scoutui::Base
3
-
4
- class QAccounts
5
-
6
-
7
- attr_accessor :dut
8
- attr_accessor :accounts
9
-
10
- def initialize(f)
11
-
12
- if !f.nil?
13
- @accounts = YAML.load_stream File.read(f)
14
- end
15
-
16
- end
17
-
18
- def _find(id, attr)
19
- hit = @accounts.find { |h| h['account']['loginid'] == id }
20
- if !hit.nil?
21
- id=hit['account'][attr]
22
- end
23
- id
24
- end
25
-
26
- def getUserRecord(u)
27
- hit=nil
28
-
29
- userid=getUserId(u)
30
- if !userid.nil?
31
- hit={'userid' => getUserId(u), 'password' => getPassword(u) }
32
- end
33
-
34
- hit
35
- end
36
-
37
- def getUserId(userid)
38
- id=nil
39
- hit = @accounts.find { |h| h['account']['loginid'].to_s == userid.to_s }
40
- if !hit.nil?
41
- id=hit['account']['loginid']
42
- end
43
- id
44
- end
45
-
46
- def getPassword(u)
47
- _find(u, 'password')
48
- end
49
-
50
- end
51
-
52
- end
@@ -1,125 +0,0 @@
1
-
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
@@ -1,74 +0,0 @@
1
-
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.getFirstObject(drv, xpath, _timeout=30)
29
- rc=nil
30
- begin
31
- Selenium::WebDriver::Wait.new(timeout: _timeout).until { drv.find_elements(:xpath => xpath).size > 0 }
32
- rc=drv.find_elements(:xpath => xpath)[0]
33
- rescue => ex
34
- ;
35
- end
36
- rc
37
- end
38
-
39
- def self.getObject(drv, xpath, _timeout=30)
40
- rc=nil
41
- begin
42
-
43
- if !xpath.match(/^page\([\w\d]+\)/).nil?
44
-
45
- xpath = Scoutui::Utils::TestUtils.instance.getPageElement(xpath)
46
- puts __FILE__ + (__LINE__).to_s + " Process page request #{xpath} => #{xpath}" if Scoutui::Utils::TestUtils.instance.isDebug?
47
- end
48
-
49
-
50
- Selenium::WebDriver::Wait.new(timeout: _timeout).until { drv.find_element(:xpath => xpath).displayed? }
51
- rc=drv.find_element(:xpath => xpath)
52
- rescue => ex
53
- ;
54
- end
55
-
56
- puts __FILE__ + (__LINE__).to_s + " getObject(#{xpath}) => #{rc.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
57
-
58
- rc
59
- end
60
-
61
- def wait_for(seconds)
62
- Selenium::WebDriver::Wait.new(timeout: seconds).until { yield }
63
- end
64
-
65
- def driver
66
- @driver
67
- end
68
-
69
-
70
-
71
- end
72
-
73
-
74
- end
@@ -1,123 +0,0 @@
1
-
2
-
3
- module Scoutui::Base
4
-
5
-
6
- class TestScout
7
- attr_reader :context
8
- attr_reader :test_settings # { host, dut }
9
- attr_reader :userRecord
10
- attr_reader :eyesRecord # {'title' , 'app'}
11
- attr_reader :eyeScout
12
- attr_reader :results
13
-
14
- def initialize(_context)
15
- @result = nil
16
- @test_settings=nil
17
- @eyesRecord=nil
18
-
19
- if Scoutui::Utils::TestUtils.instance.hasTestConfig?
20
-
21
- puts __FILE__ + (__LINE__).to_s + " * test config json => " + Scoutui::Utils::TestUtils.instance.testConfigFile() if Scoutui::Utils::TestUtils.instance.isDebug?
22
-
23
- @test_settings=Scoutui::Utils::TestUtils.instance.getTestSettings()
24
-
25
- @eyesRecord = @test_settings['eyes']
26
- end
27
-
28
- end
29
-
30
-
31
- def start
32
- if hasSettings?
33
- dumpSettings if Scoutui::Utils::TestUtils.instance.isDebug?
34
- run()
35
- end
36
- end
37
-
38
- def stop
39
- # TBD
40
- end
41
-
42
- def report
43
- @eyeScout.generateReport()
44
- end
45
-
46
- def hasSettings?
47
- Scoutui::Utils::TestUtils.instance.hasTestConfig?
48
- end
49
-
50
- def dumpSettings()
51
- puts '-' * 72
52
- puts @test_settings
53
-
54
- puts "UserRecord => #{@userRecord}"
55
- puts "Eyes Record => #{@eyesRecord}"
56
- puts "Host => #{@test_settings['host']}"
57
- end
58
-
59
- def teardown()
60
- @eyeScout.teardown()
61
- end
62
-
63
- def setup()
64
-
65
- if Scoutui::Utils::TestUtils.instance.isDebug?
66
- puts __FILE__ + (__LINE__).to_s + " eyes cfg => #{@eyesRecord}"
67
- puts __FILE__ + (__LINE__).to_s + " title => " + Scoutui::Base::UserVars.instance.getVar('eyes.title')
68
- puts __FILE__ + (__LINE__).to_s + " app => " + Scoutui::Base::UserVars.instance.getVar('eyes.app')
69
- end
70
-
71
- begin
72
-
73
- eyeScout=Scoutui::Eyes::EyeFactory.instance.createScout()
74
- rescue => ex
75
- puts ex.backtrace
76
- end
77
-
78
- eyeScout
79
- end
80
-
81
-
82
-
83
- def goto(url=nil)
84
- @eyeScout.navigate(url) if !url.nil?
85
- end
86
-
87
- def snapPage(tag)
88
- @eyeScout.check_window(tag)
89
- end
90
-
91
-
92
- def run()
93
- puts __FILE__ + (__LINE__).to_s + " run()" if Scoutui::Utils::TestUtils.instance.isDebug?
94
-
95
- begin
96
-
97
- @eyeScout=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(@eyeScout, @test_settings)
105
-
106
- teardown()
107
-
108
- rescue => ex
109
- puts ex.backtrace
110
- ensure
111
- puts __FILE__ + (__LINE__ ).to_s + " Close Eyes" if Scoutui::Utils::TestUtils.instance.isDebug?
112
- @eyeScout.closeOut()
113
-
114
- end
115
-
116
- end
117
-
118
-
119
-
120
- end
121
-
122
-
123
- end
@@ -1,109 +0,0 @@
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
-
15
-
16
- def initialize(opts)
17
- @bEyes=false
18
- @browserType=opts[:but] || :firefox
19
- @eut=opts[:eut] || :qa
20
- @lang=opts[:lang] || "en-us"
21
- @user=opts[:user] || nil
22
- @eyesReport=opts[:eyesReport] || nil
23
- @url=opts[:url]||nil
24
-
25
- end
26
-
27
- def setConfig(c)
28
- if c.instance_of?(Hash)
29
- @testConfig=c
30
- else
31
- # a JSON file was passed (ERROR handling needed)
32
- jFile = File.read(c)
33
- @testConfig=JSON.parse(jFile)
34
- end
35
-
36
- @testConfig
37
- end
38
-
39
-
40
- def getScout()
41
- @testConfig["dut"]
42
- end
43
-
44
- def setLang(lang)
45
- @lang=lang
46
- end
47
-
48
- def getUrl()
49
- @url
50
- end
51
-
52
- def url
53
- getUrl()
54
- end
55
-
56
- def setUrl(u)
57
- @url=u
58
- end
59
-
60
- def getEyesReport()
61
- @eyesReport
62
- end
63
-
64
- def getLanguage()
65
- getLang()
66
- end
67
-
68
- def getUser()
69
- @user
70
- end
71
-
72
- def getLang()
73
- @lang
74
- end
75
-
76
- def getBUT()
77
- @browserType
78
- end
79
-
80
- def setEUT(e)
81
- @eut=e
82
- end
83
-
84
- def getEUT()
85
- @eut
86
- end
87
-
88
- def browserType()
89
- @browserType
90
- end
91
-
92
- def enableEyes(b=true)
93
- @bEyes=b
94
- end
95
-
96
- def disableEyes()
97
- @bEyes=false
98
- end
99
-
100
- def isEyes?
101
- @bEyes
102
- end
103
-
104
- end
105
-
106
-
107
- end
108
-
109
-
@@ -1,105 +0,0 @@
1
- require 'singleton'
2
-
3
- module Scoutui::Base
4
-
5
- class UserVars
6
- include Singleton
7
-
8
- attr_accessor :globals
9
-
10
- def initialize
11
- @globals={
12
- :accounts => '/tmp/qa/accounts.yaml',
13
- :browser => 'chrome',
14
- :userid => nil,
15
- :password => nil,
16
- :host => nil,
17
- :localization => 'en-us'
18
- }
19
- end
20
-
21
- def dump()
22
- @globals.each_pair do |k, v|
23
- puts __FILE__ + (__LINE__).to_s + " #{k} => #{v}"
24
- end
25
- end
26
-
27
- def getViewPort()
28
- arr=Scoutui::Base::UserVars.instance.getVar('eyes.viewport').match(/(\d+)\s*x\s*(\d+)$/i)
29
- if arr.size==3
30
- _sz = {:width => arr[1].to_i, :height => arr[2].to_i }
31
- end
32
-
33
- _sz
34
- end
35
-
36
- def getBrowserType()
37
- @globals[:browser].to_sym
38
- end
39
-
40
- def getHost()
41
- @globals[:host].to_s
42
- end
43
-
44
- def get(k)
45
- foundKey=true
46
-
47
- v=k
48
-
49
- _rc = k.match(/\$\{(.*)\}$/)
50
-
51
- # Needs refactoring!
52
- if k=='${userid}'
53
- k=:userid
54
- elsif k=='${password}'
55
- k=:password
56
- elsif k=='${host}'
57
- k=:host
58
- elsif k.is_a?(Symbol)
59
- foundKey=true
60
- elsif !_rc.nil?
61
- k=_rc[1].to_s
62
- puts __FILE__ + (__LINE__).to_s + " User Var found => #{k}" if Scoutui::Utils::TestUtils.instance.isDebug?
63
- if Scoutui::Utils::TestUtils.instance.getTestConfig().has_key?("user_vars")
64
-
65
- if Scoutui::Utils::TestUtils.instance.getTestConfig()["user_vars"].has_key?(k)
66
- v=Scoutui::Utils::TestUtils.instance.getTestConfig()["user_vars"][k].to_s
67
- end
68
-
69
- end
70
-
71
- else
72
- foundKey=false
73
- end
74
-
75
- puts __FILE__ + (__LINE__).to_s + " get(#{k} => #{@globals.has_key?(k)}" if Scoutui::Utils::TestUtils.instance.isDebug?
76
-
77
- if @globals.has_key?(k) && foundKey
78
- v=@globals[k]
79
- end
80
-
81
- puts __FILE__ + (__LINE__).to_s + " get(#{k} => #{@globals.has_key?(k)} ==> #{v.to_s}" if Scoutui::Utils::TestUtils.instance.isDebug?
82
-
83
- v
84
- end
85
-
86
- def set(k, v)
87
- setVar(k, v)
88
- v
89
- end
90
-
91
- def getVar(k)
92
- @globals[k].to_s
93
- end
94
-
95
- def setVar(k, v)
96
- @globals[k]=v
97
- v
98
- end
99
-
100
-
101
- end
102
-
103
-
104
-
105
- end