eyes_selenium 1.15.0 → 1.16.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.md +2 -56
- data/lib/eyes_selenium.rb +5 -5
- data/lib/eyes_selenium/eyes/{agent_connecter.rb → agent_connector.rb} +1 -0
- data/lib/eyes_selenium/eyes/driver.rb +15 -28
- data/lib/eyes_selenium/eyes/eyes.rb +17 -7
- data/lib/eyes_selenium/eyes/eyes_mouse.rb +7 -7
- data/lib/eyes_selenium/version.rb +1 -1
- data/test_script.rb +18 -11
- metadata +4 -20
- data/spec/capybara_spec.rb +0 -34
- data/spec/driver_spec.rb +0 -10
- data/spec/eyes_spec.rb +0 -157
- data/spec/spec_helper.rb +0 -29
- data/spec/test_app.rb +0 -11
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -16,62 +16,8 @@ Or install it yourself as:
|
|
16
16
|
|
17
17
|
$ gem install eyes_selenium
|
18
18
|
|
19
|
-
##
|
20
|
-
|
21
|
-
```ruby
|
22
|
-
Applitools::Eyes.config[:apikey] = 'XXX'
|
23
|
-
|
24
|
-
eyes = Applitools::Eyes.new
|
25
|
-
eyes.test(app_name: 'my app', test_name: 'my test') do |eyes, driver|
|
26
|
-
driver.get 'http://www.mywebsite.com'
|
27
|
-
eyes.check_window('home page')
|
28
|
-
driver.find_element(:css, "li#pricing").click
|
29
|
-
eyes.check_window('pricing')
|
30
|
-
end
|
31
|
-
```
|
32
|
-
|
33
|
-
## Integrated within your Capybara tests:
|
34
|
-
initializer:
|
35
|
-
```ruby
|
36
|
-
Capybara.run_server = false
|
37
|
-
# This is your api key, make sure you use it in all your tests.
|
38
|
-
Applitools::Eyes.config[:apikey] = 'XXX'
|
39
|
-
let(:eyes) do
|
40
|
-
webdriver = page.driver.browser
|
41
|
-
eyes = Applitools::Eyes.new browser: webdriver
|
42
|
-
end
|
43
|
-
```
|
44
|
-
|
45
|
-
spec:
|
46
|
-
```ruby
|
47
|
-
require 'capybara/rspec'
|
48
|
-
require 'eyes_selenium_ruby'
|
49
|
-
|
50
|
-
|
51
|
-
describe 'Applitools', :type=>:feature, :js=>true do
|
52
|
-
|
53
|
-
describe 'Test Applitools website' do
|
54
|
-
it 'should navigate from the main page to the features page' do
|
55
|
-
|
56
|
-
# Start visual testing with browser viewport set to 1024x768.
|
57
|
-
eyes.open(app_name: 'Applitools', test_name: 'Test Web Page', viewport_size: {width: 1024, height: 768})
|
58
|
-
|
59
|
-
visit 'http://www.applitools.com'
|
60
|
-
|
61
|
-
# Visual validation point #1
|
62
|
-
eyes.check_window('Main Page')
|
63
|
-
|
64
|
-
page.first('.read_more').click
|
65
|
-
|
66
|
-
# Visual validation point #2
|
67
|
-
eyes.check_window('Features Page')
|
68
|
-
|
69
|
-
eyes.close
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
```
|
19
|
+
## Usage
|
20
|
+
Please check the applitools website for usage instructions: http://www.applitools.com
|
75
21
|
|
76
22
|
## Contributing
|
77
23
|
|
data/lib/eyes_selenium.rb
CHANGED
@@ -16,12 +16,12 @@ module Applitools
|
|
16
16
|
class NewTestError < TestFailedError; end
|
17
17
|
|
18
18
|
require 'eyes_selenium/utils'
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
19
|
+
require 'eyes_selenium/version'
|
20
|
+
require 'eyes_selenium/eyes/agent_connector'
|
21
|
+
require 'eyes_selenium/eyes/target_app'
|
22
22
|
require 'eyes_selenium/eyes/batch_info'
|
23
|
-
require
|
24
|
-
require
|
23
|
+
require 'eyes_selenium/eyes/dimension'
|
24
|
+
require 'eyes_selenium/eyes/driver'
|
25
25
|
require 'eyes_selenium/eyes/element'
|
26
26
|
require 'eyes_selenium/eyes/environment'
|
27
27
|
require 'eyes_selenium/eyes/eyes'
|
@@ -3,6 +3,7 @@ class Applitools::AgentConnector
|
|
3
3
|
include HTTParty
|
4
4
|
headers 'Accept' => 'application/json'
|
5
5
|
ssl_ca_file File.join(File.dirname(File.expand_path(__FILE__)), '../../../certs/cacert.pem').to_s
|
6
|
+
default_timeout 300
|
6
7
|
#debug_output $stdout # comment out when not debugging
|
7
8
|
|
8
9
|
attr_reader :uri, :auth
|
@@ -5,38 +5,25 @@ class Applitools::Driver
|
|
5
5
|
include Selenium::WebDriver::DriverExtensions::HasInputDevices
|
6
6
|
|
7
7
|
attr_reader :remote_server_url, :remote_session_id, :user_agent, :screenshot_taker
|
8
|
-
attr_accessor :user_inputs, :
|
8
|
+
attr_accessor :user_inputs, :driver
|
9
9
|
|
10
|
-
DEFAULT_DRIVER = :firefox
|
11
10
|
DRIVER_METHODS = [
|
12
11
|
:title, :execute_script, :execute_async_script, :quit, :close, :get,
|
13
12
|
:post, :page_source, :window_handles, :window_handle, :switch_to,
|
14
13
|
:navigate, :manage, :capabilities
|
15
14
|
]
|
16
15
|
|
17
|
-
## If driver is not provided, Applitools::Driver will
|
18
|
-
## Driver param can be a Selenium::WebDriver or a named symbol (:chrome)
|
16
|
+
## If driver is not provided, Applitools::Driver will raise an EyesError exception.
|
19
17
|
#
|
20
|
-
|
21
|
-
|
22
|
-
# eyes.open(browser: Selenium::WebDriver.for(:chrome) ##=> will create the same thing
|
23
|
-
# eyes.open ##=> will create a webdriver according to Applitools::Driver::DEFAULT_DRIVER
|
24
|
-
def initialize(options={})
|
25
|
-
browser_obj = options.delete(:browser) || DEFAULT_DRIVER
|
26
|
-
@browser ||= case browser_obj
|
27
|
-
when Symbol
|
28
|
-
at_exit { quit rescue nil }
|
29
|
-
Selenium::WebDriver.for browser_obj
|
30
|
-
else
|
31
|
-
browser_obj
|
32
|
-
end
|
18
|
+
def initialize(options)
|
19
|
+
@driver = options[:driver]
|
33
20
|
|
34
21
|
@user_inputs = []
|
35
22
|
@remote_server_url = address_of_remote_server
|
36
23
|
@remote_session_id = remote_session_id
|
37
24
|
@user_agent = get_user_agent
|
38
25
|
begin
|
39
|
-
if
|
26
|
+
if driver.capabilities.takes_screenshot?
|
40
27
|
@screenshot_taker = false
|
41
28
|
else
|
42
29
|
@screenshot_taker = Applitools::ScreenshotTaker.new(@remote_server_url, @remote_session_id)
|
@@ -48,12 +35,12 @@ class Applitools::Driver
|
|
48
35
|
|
49
36
|
DRIVER_METHODS.each do |method|
|
50
37
|
define_method method do |*args, &block|
|
51
|
-
|
38
|
+
driver.send(method,*args, &block)
|
52
39
|
end
|
53
40
|
end
|
54
41
|
|
55
42
|
def screenshot_as(output_type)
|
56
|
-
return
|
43
|
+
return driver.screenshot_as(output_type) if !screenshot_taker
|
57
44
|
|
58
45
|
if output_type.downcase.to_sym != :base64
|
59
46
|
raise Applitools::EyesError.new("#{output_type} ouput type not supported for screenshot")
|
@@ -62,19 +49,19 @@ class Applitools::Driver
|
|
62
49
|
end
|
63
50
|
|
64
51
|
def mouse
|
65
|
-
Applitools::EyesMouse.new(self,
|
52
|
+
Applitools::EyesMouse.new(self, driver.mouse)
|
66
53
|
end
|
67
54
|
|
68
55
|
def keyboard
|
69
|
-
Applitools::EyesKeyboard.new(self,
|
56
|
+
Applitools::EyesKeyboard.new(self, driver.keyboard)
|
70
57
|
end
|
71
58
|
|
72
59
|
def find_element(by, selector)
|
73
|
-
Applitools::Element.new(self,
|
60
|
+
Applitools::Element.new(self, driver.find_element(by, selector))
|
74
61
|
end
|
75
62
|
|
76
63
|
def find_elements(by, selector)
|
77
|
-
|
64
|
+
driver.find_elements(by, selector).map { |el| Applitools::Element.new(self, el) }
|
78
65
|
end
|
79
66
|
|
80
67
|
def create_application
|
@@ -86,17 +73,17 @@ class Applitools::Driver
|
|
86
73
|
end
|
87
74
|
|
88
75
|
def ie?
|
89
|
-
|
76
|
+
driver.to_s == 'ie'
|
90
77
|
end
|
91
78
|
|
92
79
|
def firefox?
|
93
|
-
|
80
|
+
driver.to_s == 'firefox'
|
94
81
|
end
|
95
82
|
|
96
83
|
private
|
97
84
|
|
98
85
|
def address_of_remote_server
|
99
|
-
uri = URI(
|
86
|
+
uri = URI(driver.current_url)
|
100
87
|
raise Applitools::EyesError.new("Failed to get remote web driver url") if uri.to_s.empty?
|
101
88
|
|
102
89
|
webdriver_host = uri.host
|
@@ -108,7 +95,7 @@ class Applitools::Driver
|
|
108
95
|
end
|
109
96
|
|
110
97
|
def remote_session_id
|
111
|
-
|
98
|
+
driver.remote_session_id
|
112
99
|
end
|
113
100
|
|
114
101
|
def get_user_agent
|
@@ -37,14 +37,16 @@ class Applitools::Eyes
|
|
37
37
|
@failure_reports = Applitools::FailureReports::ON_CLOSE
|
38
38
|
end
|
39
39
|
|
40
|
-
def create_driver(params)
|
41
|
-
Applitools::Driver.new(browser: params.fetch(:browser, nil))
|
42
|
-
end
|
43
|
-
|
44
40
|
def open(params={})
|
45
|
-
@driver =
|
41
|
+
@driver = get_driver(params)
|
46
42
|
return driver if disabled?
|
47
43
|
|
44
|
+
if driver.nil? || !driver.is_a?(Selenium::WebDriver::Driver)
|
45
|
+
raise Applitools::EyesError.new("driver/browser must be a valid Selenium webdriver")
|
46
|
+
end
|
47
|
+
|
48
|
+
@driver = Applitools::Driver.new(driver: @driver)
|
49
|
+
|
48
50
|
if open?
|
49
51
|
abort_if_not_closed
|
50
52
|
msg = 'a test is alread running'
|
@@ -126,8 +128,7 @@ class Applitools::Eyes
|
|
126
128
|
open(params)
|
127
129
|
yield(driver)
|
128
130
|
close
|
129
|
-
|
130
|
-
ensure
|
131
|
+
ensure
|
131
132
|
abort_if_not_closed
|
132
133
|
end
|
133
134
|
end
|
@@ -153,6 +154,15 @@ class Applitools::Eyes
|
|
153
154
|
disabled
|
154
155
|
end
|
155
156
|
|
157
|
+
def get_driver(params)
|
158
|
+
# TODO remove the "browser" related block when possible. It's for backward compatibility.
|
159
|
+
if params.has_key?(:browser)
|
160
|
+
EyesLogger.info('"browser" key is deprecated, please use "driver" instead.')
|
161
|
+
return params[:browser]
|
162
|
+
end
|
163
|
+
params.fetch(:driver, nil)
|
164
|
+
end
|
165
|
+
|
156
166
|
def start_session
|
157
167
|
assign_viewport_size
|
158
168
|
test_batch ||= Applitools::BatchInfo.new
|
@@ -29,8 +29,8 @@ class Applitools::EyesMouse
|
|
29
29
|
def move_to(element, right_by = nil, down_by = nil)
|
30
30
|
element = element.web_element if element.is_a?(Applitools::Element)
|
31
31
|
location = element.location
|
32
|
-
location.x = [0,location.x].max
|
33
|
-
location.y = [0,location.y].max
|
32
|
+
location.x = [0,location.x].max.round
|
33
|
+
location.y = [0,location.y].max.round
|
34
34
|
current_control = Applitools::Region.new(0,0, *location.values)
|
35
35
|
driver.user_inputs << Applitools::MouseTrigger.new(:move, current_control, location)
|
36
36
|
element = element.web_element if element.is_a?(Applitools::Element)
|
@@ -38,9 +38,9 @@ class Applitools::EyesMouse
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def move_by(right_by, down_by)
|
41
|
-
right = [0,right_by].max
|
42
|
-
down = [0,down_by].max
|
43
|
-
location = Selenium::WebDriver::
|
41
|
+
right = [0,right_by].max.round
|
42
|
+
down = [0,down_by].max.round
|
43
|
+
location = Selenium::WebDriver::Point.new(right,down)
|
44
44
|
current_control = Applitools::Region.new(0,0, right, down)
|
45
45
|
driver.user_inputs << Applitools::MouseTrigger.new(:move, current_control, location)
|
46
46
|
mouse.move_by(right_by,down_by)
|
@@ -50,8 +50,8 @@ class Applitools::EyesMouse
|
|
50
50
|
|
51
51
|
def extract_trigger_and_perform(method, element=nil, *args)
|
52
52
|
location = element.location
|
53
|
-
location.x = [0,location.x].max
|
54
|
-
location.y = [0,location.y].max
|
53
|
+
location.x = [0,location.x].max.round
|
54
|
+
location.y = [0,location.y].max.round
|
55
55
|
current_control = Applitools::Region.new(0,0, *location.values)
|
56
56
|
driver.user_inputs << Applitools::MouseTrigger.new(method, current_control, location)
|
57
57
|
element = element.web_element if element.is_a?(Applitools::Element)
|
data/test_script.rb
CHANGED
@@ -7,15 +7,22 @@ require 'eyes_selenium'
|
|
7
7
|
Applitools::Eyes.config[:apikey] = 'YOUR_API_KEY'
|
8
8
|
|
9
9
|
eyes = Applitools::Eyes.new
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
eyes.
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
10
|
+
|
11
|
+
my_webdriver = Selenium::WebDriver.for :firefox
|
12
|
+
|
13
|
+
begin
|
14
|
+
eyes.test(app_name: 'Ruby SDK', test_name: 'Applitools website test', viewport_size: {width: 1024, height: 768}, driver: my_webdriver) do |driver|
|
15
|
+
driver.get "http://www.applitools.com"
|
16
|
+
eyes.check_window("initial")
|
17
|
+
driver.find_element(:css, "li.pricing a").click
|
18
|
+
eyes.check_window("pricing page")
|
19
|
+
el = driver.find_elements(:css, ".footer-row a").first
|
20
|
+
driver.action.double_click(el).perform
|
21
|
+
eyes.check_window("in forms")
|
22
|
+
other_el = driver.find_elements(:css, ".s2member-pro-paypal-registration-email").first
|
23
|
+
driver.action.move_to(other_el).click(other_el).send_keys("applitools").perform
|
24
|
+
eyes.check_window("end")
|
25
|
+
end
|
26
|
+
ensure
|
27
|
+
my_webdriver.quit
|
21
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eyes_selenium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.16.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: selenium-webdriver
|
@@ -156,7 +156,7 @@ files:
|
|
156
156
|
- eyes_selenium.gemspec
|
157
157
|
- lib/eyes_selenium.rb
|
158
158
|
- lib/eyes_selenium/capybara.rb
|
159
|
-
- lib/eyes_selenium/eyes/
|
159
|
+
- lib/eyes_selenium/eyes/agent_connector.rb
|
160
160
|
- lib/eyes_selenium/eyes/batch_info.rb
|
161
161
|
- lib/eyes_selenium/eyes/dimension.rb
|
162
162
|
- lib/eyes_selenium/eyes/driver.rb
|
@@ -182,11 +182,6 @@ files:
|
|
182
182
|
- lib/eyes_selenium/utils.rb
|
183
183
|
- lib/eyes_selenium/utils/image_delta_compressor.rb
|
184
184
|
- lib/eyes_selenium/version.rb
|
185
|
-
- spec/capybara_spec.rb
|
186
|
-
- spec/driver_spec.rb
|
187
|
-
- spec/eyes_spec.rb
|
188
|
-
- spec/spec_helper.rb
|
189
|
-
- spec/test_app.rb
|
190
185
|
- test_script.rb
|
191
186
|
homepage: http://www.applitools.com
|
192
187
|
licenses:
|
@@ -201,27 +196,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
201
196
|
- - ! '>='
|
202
197
|
- !ruby/object:Gem::Version
|
203
198
|
version: '0'
|
204
|
-
segments:
|
205
|
-
- 0
|
206
|
-
hash: -2476420457327612730
|
207
199
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
208
200
|
none: false
|
209
201
|
requirements:
|
210
202
|
- - ! '>='
|
211
203
|
- !ruby/object:Gem::Version
|
212
204
|
version: '0'
|
213
|
-
segments:
|
214
|
-
- 0
|
215
|
-
hash: -2476420457327612730
|
216
205
|
requirements: []
|
217
206
|
rubyforge_project:
|
218
207
|
rubygems_version: 1.8.25
|
219
208
|
signing_key:
|
220
209
|
specification_version: 3
|
221
210
|
summary: Applitools Ruby SDK
|
222
|
-
test_files:
|
223
|
-
- spec/capybara_spec.rb
|
224
|
-
- spec/driver_spec.rb
|
225
|
-
- spec/eyes_spec.rb
|
226
|
-
- spec/spec_helper.rb
|
227
|
-
- spec/test_app.rb
|
211
|
+
test_files: []
|
data/spec/capybara_spec.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'capybara/rspec'
|
3
|
-
require 'eyes_selenium/capybara'
|
4
|
-
require 'test_app'
|
5
|
-
|
6
|
-
Capybara.app = TestApp
|
7
|
-
|
8
|
-
describe Applitools::Eyes do
|
9
|
-
init_eyes
|
10
|
-
describe 'capybara' do
|
11
|
-
before do
|
12
|
-
eyes.agent_connector.stub(:stop_session).and_return(double("TestResults", mismatches: 0, missing: 0))
|
13
|
-
eyes.agent_connector.stub(:match_window).and_return(true)
|
14
|
-
@navigation = double("navigation")
|
15
|
-
@navigation.stub(:to)
|
16
|
-
end
|
17
|
-
it 'should invoke eyes driver when calling capybara visit inside of eyes.open' do
|
18
|
-
Capybara.current_driver.should == :rack_test
|
19
|
-
|
20
|
-
eyes.driver.should_receive(:navigate).and_return(@navigation)
|
21
|
-
eyes.test(app_name: 'test', test_name: 'test') do |eyes|
|
22
|
-
Capybara.current_driver.should == :selenium
|
23
|
-
eyes.driver.should == Capybara.current_session.driver.instance_variable_get(:@browser)
|
24
|
-
Capybara.current_session.visit '/'
|
25
|
-
eyes.check_window('test')
|
26
|
-
end
|
27
|
-
Capybara.current_driver.should == :rack_test
|
28
|
-
end
|
29
|
-
it 'should not invoke eyes driver when calling capybara visit outside of eyes.open' do
|
30
|
-
eyes.driver.should_not_receive(:navigate)
|
31
|
-
Capybara.current_session.visit '/'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
data/spec/driver_spec.rb
DELETED
data/spec/eyes_spec.rb
DELETED
@@ -1,157 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Applitools::Eyes do
|
4
|
-
init_eyes
|
5
|
-
|
6
|
-
before do
|
7
|
-
eyes.open(app_name: 'test_app', test_name: 'test_app_test')
|
8
|
-
fake_session = Applitools::Session.new(1,"http://fake_url.com", false)
|
9
|
-
eyes.session = fake_session
|
10
|
-
eyes.agent_connector.stub(:stop_session).and_return(double("TestResults", mismatches: 0, missing: 0))
|
11
|
-
eyes.agent_connector.stub(:match_window).and_return(true)
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "#new" do
|
15
|
-
context "doesn't have an apikey" do
|
16
|
-
before do
|
17
|
-
Applitools::Eyes.config[:apikey] = nil
|
18
|
-
end
|
19
|
-
it {expect {Applitools::Eyes.new }.to raise_error }
|
20
|
-
after do
|
21
|
-
Applitools::Eyes.config[:apikey] = 'YOUR_API_KEY_HERE'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
context "has an apikey url" do
|
25
|
-
it {expect {Applitools::Eyes.new }.to_not raise_error }
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe ".open" do
|
30
|
-
context "already open" do
|
31
|
-
it "aborts session" do
|
32
|
-
eyes.should_receive(:abort_if_not_closed)
|
33
|
-
expect {eyes.open}.to raise_error
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
describe ".abort_if_not_closed" do
|
40
|
-
it "closes eyes" do
|
41
|
-
expect(eyes).to be_open
|
42
|
-
eyes.send(:abort_if_not_closed)
|
43
|
-
expect(eyes).to_not be_open
|
44
|
-
end
|
45
|
-
|
46
|
-
it "clears session" do
|
47
|
-
eyes.send(:abort_if_not_closed)
|
48
|
-
expect(eyes.session).to be_nil
|
49
|
-
end
|
50
|
-
|
51
|
-
it "stops session" do
|
52
|
-
expect(eyes.agent_connector).to receive(:stop_session)
|
53
|
-
eyes.send(:abort_if_not_closed)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe ".close" do
|
58
|
-
it "stops the session" do
|
59
|
-
eyes.agent_connector.stub(:stop_session).and_return(double("TestResults", mismatches: 0, missing: 0))
|
60
|
-
expect(eyes.agent_connector).to receive(:stop_session)
|
61
|
-
expect(eyes.close)
|
62
|
-
end
|
63
|
-
|
64
|
-
context "new_session" do
|
65
|
-
before { eyes.session.stub(:new_session?).and_return(true) }
|
66
|
-
it "raises NewTestError" do
|
67
|
-
eyes.session_start_info = double().as_null_object
|
68
|
-
expect { eyes.close }.to raise_error(Applitools::NewTestError)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context "not new_session" do
|
73
|
-
before do
|
74
|
-
eyes.stub(:session_start_info).and_return double().as_null_object
|
75
|
-
eyes.session.new_session = false
|
76
|
-
end
|
77
|
-
|
78
|
-
it "raises TestFailedError if results have mismatches" do
|
79
|
-
eyes.agent_connector.stub(:stop_session).and_return(double("TestResults", mismatches: 2))
|
80
|
-
expect { eyes.close }.to raise_error(Applitools::TestFailedError)
|
81
|
-
end
|
82
|
-
|
83
|
-
it "raises TestFailedError if results have missing" do
|
84
|
-
eyes.agent_connector.stub(:stop_session).and_return(double("TestResults", mismatches: 0, missing: 2))
|
85
|
-
expect { eyes.close }.to raise_error(Applitools::TestFailedError)
|
86
|
-
end
|
87
|
-
|
88
|
-
it "doesn't raise if old session without mismatches" do
|
89
|
-
eyes.stub_chain(:agent_connector, :stop_session).and_return(double("TestResults", mismatches: 0, missing: 0))
|
90
|
-
expect(eyes.close).to_not raise_error
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe ".check_window" do
|
96
|
-
it "raises EyesError if eyes aren't open"
|
97
|
-
context "no session" do
|
98
|
-
it "creates new session if no session exists"
|
99
|
-
it "creates new MatchWindowTask"
|
100
|
-
end
|
101
|
-
|
102
|
-
context "results are as expected" do
|
103
|
-
it "doesn't raise"
|
104
|
-
end
|
105
|
-
context "results are not as expected" do
|
106
|
-
context "new session" do
|
107
|
-
specify "next check_window will run once on time out"
|
108
|
-
end
|
109
|
-
context "not new session" do
|
110
|
-
context "immediate failreports" do
|
111
|
-
it "raises TestFailedError"
|
112
|
-
end
|
113
|
-
|
114
|
-
context "not immediate failreports" do
|
115
|
-
it "doesn't raise"
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
describe ".test" do
|
122
|
-
it "opens and closes the eyes around the block execution" do
|
123
|
-
eyes.should_receive(:open).ordered
|
124
|
-
eyes.should_receive(:close).ordered
|
125
|
-
eyes.test { "foo" }
|
126
|
-
end
|
127
|
-
|
128
|
-
it "always closes eyes even if there were exceptions" do
|
129
|
-
eyes.stub(:open)
|
130
|
-
eyes.should_receive(:abort_if_not_closed)
|
131
|
-
eyes.test { raise Applitools::EyesError }
|
132
|
-
end
|
133
|
-
|
134
|
-
context "testing .test" do
|
135
|
-
let!(:eyes) do
|
136
|
-
Applitools::Eyes.new
|
137
|
-
end
|
138
|
-
it "catches triggers" do
|
139
|
-
eyes.send(:abort_if_not_closed)
|
140
|
-
eyes.test(app_name: 'my app1', test_name: 'my test') do |eyes, driver|
|
141
|
-
driver.get "http://www.applitools.com"
|
142
|
-
eyes.check_window("initial")
|
143
|
-
driver.find_element(:css, "li.pricing a").click
|
144
|
-
# return false unless user_inputs.map(&:to_hash) == [{"$type"=>"Applitools.Models.MouseTrigger, Core", :mouseAction=>1, :control=>{"$type"=>"Applitools.Utils.Geometry.MutableRegion, Core", :left=>555, :top=>0, :height=>69, :width=>50}, :location=>{:latitude=>25, :longitude=>34, :altitude=>nil}}]
|
145
|
-
eyes.check_window("pricing page")
|
146
|
-
el = driver.find_elements(:css, ".footer-row a").first
|
147
|
-
driver.action.double_click(el).perform
|
148
|
-
# return false unless user_inputs.map(&:to_hash) == [{"$type"=>"Applitools.Models.MouseTrigger, Core", :mouseAction=>3, :control=>{"$type"=>"Applitools.Utils.Geometry.MutableRegion, Core", :left=>0, :top=>0, :height=>115, :width=>376}, :location=>{:x=>115, :y=>376}}]
|
149
|
-
eyes.check_window("in forms")
|
150
|
-
other_el = driver.find_elements(:css, ".s2member-pro-paypal-registration-email").first
|
151
|
-
driver.action.move_to(other_el).click(other_el).send_keys("text1",:space,"text2").perform
|
152
|
-
# return false unless user_inputs.map(&:to_hash) == [{"$type"=>"Applitools.Models.MouseTrigger, Core", :mouseAction=>4, :control=>{"$type"=>"Applitools.Utils.Geometry.MutableRegion, Core", :left=>0, :top=>0, :height=>230, :width=>331}, :location=>{:x=>230, :y=>331}}, {"$type"=>"Applitools.Models.MouseTrigger, Core", :mouseAction=>1, :control=>{"$type"=>"Applitools.Utils.Geometry.MutableRegion, Core", :left=>0, :top=>0, :height=>230, :width=>331}, :location=>{:x=>230, :y=>331}}, {"$type"=>"Applitools.Models.TextTrigger, Core", :text=>"text1", :control=>{"$type"=>"Applitools.Utils.Geometry.MutableRegion, Core", :left=>230, :top=>331, :height=>367, :width=>35}}, {"$type"=>"Applitools.Models.TextTrigger, Core", :text=>"", :control=>{"$type"=>"Applitools.Utils.Geometry.MutableRegion, Core", :left=>230, :top=>331, :height=>367, :width=>35}}, {"$type"=>"Applitools.Models.TextTrigger, Core", :text=>"text2", :control=>{"$type"=>"Applitools.Utils.Geometry.MutableRegion, Core", :left=>230, :top=>331, :height=>367, :width=>35}}]
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
-
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
-
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
-
# loaded once.
|
5
|
-
#
|
6
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
-
require 'eyes_selenium'
|
8
|
-
RSpec.configure do |config|
|
9
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
10
|
-
config.run_all_when_everything_filtered = true
|
11
|
-
config.filter_run :focus
|
12
|
-
|
13
|
-
# Run specs in random order to surface order dependencies. If you find an
|
14
|
-
# order dependency and want to debug it, you can fix the order by providing
|
15
|
-
# the seed, which is printed after each run.
|
16
|
-
# --seed 1234
|
17
|
-
config.order = 'random'
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
def init_eyes
|
22
|
-
before(:all) do
|
23
|
-
Applitools::Eyes.config[:apikey] = 'YOUR_API_KEY'
|
24
|
-
Applitools::Eyes.config[:server_url] = 'http://eyes.applitools.com'
|
25
|
-
end
|
26
|
-
let!(:eyes) do
|
27
|
-
Applitools::Eyes.new
|
28
|
-
end
|
29
|
-
end
|