eyes_selenium 2.32.0 → 2.33.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/eyes_selenium.gemspec +1 -0
- data/lib/applitools/selenium/browser.rb +0 -4
- data/lib/applitools/selenium/driver.rb +2 -2
- data/lib/applitools/selenium/match_window_task.rb +1 -1
- data/lib/applitools/utils/image_utils.rb +21 -12
- data/lib/applitools/version.rb +1 -1
- data/test/capybara_example.rb +43 -0
- data/test/sauce_capybara_check.rb +38 -0
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0761083944ac62eddd2754e25e1a99df2f552d42
|
4
|
+
data.tar.gz: 618d2ce2130371f1215290c33adf565b76435b4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e307d5656b5e228b5497b505f44ec611d9b58e6adb767b6142e8aafa8b302ac8432fc3decca3f219d235534a4056200ca49beb4f7ae152b8e3aeb7eb9a3ce3df
|
7
|
+
data.tar.gz: 9ce50824573c8e1508e3f9a1af24343730db7a6f0f96ed53238bc364a93c0aaba96d77df2b71be9a755d36782befca19aa5ece72dcd44e4b479618be405158e6
|
data/eyes_selenium.gemspec
CHANGED
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
|
26
26
|
spec.add_development_dependency 'bundler'
|
27
27
|
spec.add_development_dependency 'rake'
|
28
|
+
spec.add_development_dependency 'capybara'
|
28
29
|
spec.add_development_dependency 'rspec', '>= 3'
|
29
30
|
spec.add_development_dependency 'watir-webdriver'
|
30
31
|
spec.add_development_dependency 'appium_lib'
|
@@ -181,14 +181,10 @@ module Applitools::Selenium
|
|
181
181
|
|
182
182
|
process_screenshot_part(screenshot_part, size_factor)
|
183
183
|
end
|
184
|
-
|
185
184
|
screenshot = Applitools::Utils::ImageUtils.stitch_images(page_size, parts)
|
186
185
|
end
|
187
|
-
|
188
186
|
set_transform(original_transform) if @eyes.use_css_transition
|
189
|
-
|
190
187
|
scroll_to(original_scroll_position)
|
191
|
-
|
192
188
|
screenshot
|
193
189
|
end
|
194
190
|
|
@@ -40,7 +40,7 @@ module Applitools::Selenium
|
|
40
40
|
@wait_before_screenshots = 0
|
41
41
|
@eyes = eyes
|
42
42
|
@browser = Applitools::Selenium::Browser.new(self, @eyes)
|
43
|
-
Applitools::EyesLogger.warn '"
|
43
|
+
Applitools::EyesLogger.warn '"screenshot_as" method not found!' unless driver.respond_to? :screenshot_as
|
44
44
|
end
|
45
45
|
|
46
46
|
# Returns:
|
@@ -100,7 +100,7 @@ module Applitools::Selenium
|
|
100
100
|
Applitools::EyesLogger.debug "Waiting before screenshot: #{wait_before_screenshots} seconds..."
|
101
101
|
sleep(wait_before_screenshots)
|
102
102
|
Applitools::EyesLogger.debug 'Finished waiting.'
|
103
|
-
Applitools::Utils::ImageUtils.
|
103
|
+
Applitools::Utils::ImageUtils::Screenshot.new driver.screenshot_as(:png)
|
104
104
|
end
|
105
105
|
|
106
106
|
def mouse
|
@@ -103,7 +103,7 @@ module Applitools::Selenium
|
|
103
103
|
title = eyes.title
|
104
104
|
Applitools::EyesLogger.debug 'Getting screenshot...'
|
105
105
|
Applitools::EyesLogger.debug 'Done! Creating image object from PNG...'
|
106
|
-
@current_screenshot =
|
106
|
+
@current_screenshot = driver.get_screenshot(rotation)
|
107
107
|
Applitools::EyesLogger.debug 'Done!'
|
108
108
|
# If a region was defined, we refer to the sub-image defined by the region.
|
109
109
|
unless region.empty?
|
@@ -74,7 +74,7 @@ module Applitools::Utils
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def stitch_images(size, images_data)
|
77
|
-
ChunkyPNG::Image.new(size.width, size.height, ChunkyPNG::Color::TRANSPARENT).tap do |res|
|
77
|
+
stitched_screenshot = ChunkyPNG::Image.new(size.width, size.height, ChunkyPNG::Color::TRANSPARENT).tap do |res|
|
78
78
|
images_data.each do |image_data|
|
79
79
|
# Crop out of bounds images.
|
80
80
|
image = image_data.image
|
@@ -84,30 +84,41 @@ module Applitools::Utils
|
|
84
84
|
new_height = position.top + image.height > size.height ? size.height - position.top : image.height
|
85
85
|
|
86
86
|
if new_width != image.width || new_height != image.height
|
87
|
-
image = image.crop(0, 0, new_width, new_height)
|
87
|
+
image = image.crop!(0, 0, new_width, new_height)
|
88
88
|
end
|
89
89
|
|
90
|
-
res.
|
90
|
+
res.replace!(image.restore, position.left, position.top)
|
91
|
+
GC.start
|
91
92
|
end
|
92
93
|
end
|
94
|
+
result = Applitools::Utils::ImageUtils::Screenshot.new stitched_screenshot.to_blob.dup
|
95
|
+
GC.start
|
96
|
+
result
|
93
97
|
end
|
94
98
|
|
95
99
|
class Screenshot < Delegator
|
96
|
-
|
100
|
+
extend Forwardable
|
101
|
+
def_delegators :header, :width, :height
|
97
102
|
|
98
103
|
def initialize(image)
|
99
|
-
@
|
100
|
-
|
101
|
-
|
102
|
-
|
104
|
+
@datastream = ChunkyPNG::Datastream.from_string image
|
105
|
+
end
|
106
|
+
|
107
|
+
def to_blob
|
108
|
+
@datastream.to_blob
|
103
109
|
end
|
104
110
|
|
105
111
|
def __getobj__
|
106
112
|
restore
|
107
113
|
end
|
108
114
|
|
115
|
+
def header
|
116
|
+
@datastream.header_chunk
|
117
|
+
end
|
118
|
+
|
109
119
|
def __setobj__(obj)
|
110
|
-
obj.
|
120
|
+
@datastream = obj.to_datastream
|
121
|
+
self
|
111
122
|
end
|
112
123
|
|
113
124
|
def method_missing(method, *args, &block)
|
@@ -118,10 +129,8 @@ module Applitools::Utils
|
|
118
129
|
end
|
119
130
|
end
|
120
131
|
|
121
|
-
private
|
122
|
-
|
123
132
|
def restore
|
124
|
-
ChunkyPNG::Image.
|
133
|
+
ChunkyPNG::Image.from_datastream @datastream
|
125
134
|
end
|
126
135
|
end
|
127
136
|
|
data/lib/applitools/version.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'capybara/rspec'
|
3
|
+
require_relative '../lib/eyes_selenium'
|
4
|
+
require 'openssl'
|
5
|
+
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
6
|
+
|
7
|
+
|
8
|
+
Capybara.register_driver :selenium do |app|
|
9
|
+
Capybara::Selenium::Driver.new(app, :browser => :chrome)
|
10
|
+
end
|
11
|
+
|
12
|
+
Capybara.javascript_driver = :selenium
|
13
|
+
|
14
|
+
# require 'capybara/poltergeist'
|
15
|
+
#
|
16
|
+
# Capybara.register_driver :poltergeist_app do |app|
|
17
|
+
# Capybara::Poltergeist::Driver.new(app, :js_errors => false)
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# Capybara.javascript_driver = :poltergeist_app
|
21
|
+
|
22
|
+
|
23
|
+
describe 'Capybara Example', :type => :feature, :js => true do
|
24
|
+
before :each do
|
25
|
+
@eyes = Applitools::Eyes.new
|
26
|
+
@eyes.api_key = ENV['APPLITOOLS_API_KEY']
|
27
|
+
@eyes.log_handler = Logger.new(STDOUT)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'Simple test' do
|
31
|
+
driver = @eyes.open(app_name: 'Ruby SDK', test_name: 'Capybara test', driver: page.driver.browser, viewport_size: {width: 800, height: 600})
|
32
|
+
visit 'http://github.com'
|
33
|
+
@eyes.check_window('homepage')
|
34
|
+
username = driver.find_element(:name, 'user[login]')
|
35
|
+
username.send_keys('user')
|
36
|
+
@eyes.check_window('homepage with username')
|
37
|
+
@eyes.close
|
38
|
+
end
|
39
|
+
|
40
|
+
after :each do
|
41
|
+
@eyes.abort_if_not_closed
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'capybara'
|
2
|
+
require 'sauce'
|
3
|
+
require 'sauce/capybara'
|
4
|
+
require_relative '../lib/eyes_selenium'
|
5
|
+
require 'openssl'
|
6
|
+
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
7
|
+
|
8
|
+
Sauce.config do |config|
|
9
|
+
config[:browsers] = [
|
10
|
+
["OS X 10.10", "chrome", "39.0"]
|
11
|
+
]
|
12
|
+
config[:start_tunnel] = false
|
13
|
+
# config[:sauce_connect_4_executable] = '/path/to/sauce-connect/bin/sc'
|
14
|
+
end
|
15
|
+
|
16
|
+
Capybara.javascript_driver = :sauce
|
17
|
+
|
18
|
+
describe 'A Saucy Example Group', :sauce => true do
|
19
|
+
before :each do
|
20
|
+
@eyes = Applitools::Eyes.new
|
21
|
+
@eyes.api_key = ENV['APPLITOOLS_API_KEY']
|
22
|
+
@eyes.log_handler = Logger.new(STDOUT)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'Simple test' do
|
26
|
+
driver = @eyes.open(app_name: 'Ruby SDK', test_name: 'Capybara test', driver: selenium.driver, viewport_size: {width: 800, height: 600})
|
27
|
+
driver.navigate.to 'http://github.com'
|
28
|
+
@eyes.check_window('homepage')
|
29
|
+
username = driver.find_element(:name, 'user[login]')
|
30
|
+
username.send_keys('user')
|
31
|
+
@eyes.check_window('homepage with username')
|
32
|
+
@eyes.close(false)
|
33
|
+
end
|
34
|
+
|
35
|
+
after :each do
|
36
|
+
@eyes.abort_if_not_closed
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eyes_selenium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.33.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Applitools Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selenium-webdriver
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: capybara
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rspec
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -256,6 +270,8 @@ files:
|
|
256
270
|
- spec/fixtures/static_test_file.html
|
257
271
|
- spec/spec_helper.rb
|
258
272
|
- test/appium_example_script.rb
|
273
|
+
- test/capybara_example.rb
|
274
|
+
- test/sauce_capybara_check.rb
|
259
275
|
- test/test_script.rb
|
260
276
|
- test/watir_test_script.rb
|
261
277
|
homepage: https://www.applitools.com
|
@@ -287,6 +303,8 @@ test_files:
|
|
287
303
|
- spec/fixtures/static_test_file.html
|
288
304
|
- spec/spec_helper.rb
|
289
305
|
- test/appium_example_script.rb
|
306
|
+
- test/capybara_example.rb
|
307
|
+
- test/sauce_capybara_check.rb
|
290
308
|
- test/test_script.rb
|
291
309
|
- test/watir_test_script.rb
|
292
310
|
has_rdoc:
|