eyes_selenium 2.16.0 → 2.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +54 -0
- data/.travis.yml +2 -0
- data/Rakefile +3 -0
- data/eyes_selenium.gemspec +3 -2
- data/lib/applitools/base/image_position.rb +10 -0
- data/lib/applitools/base/mouse_trigger.rb +1 -1
- data/lib/applitools/base/point.rb +18 -5
- data/lib/applitools/base/region.rb +44 -9
- data/lib/applitools/base/server_connector.rb +7 -6
- data/lib/applitools/base/test_results.rb +4 -5
- data/lib/applitools/extensions.rb +17 -0
- data/lib/applitools/eyes.rb +40 -32
- data/lib/applitools/eyes_logger.rb +7 -7
- data/lib/applitools/method_tracer.rb +2 -2
- data/lib/applitools/selenium/browser.rb +220 -0
- data/lib/applitools/selenium/driver.rb +61 -59
- data/lib/applitools/selenium/element.rb +10 -5
- data/lib/applitools/selenium/match_window_data.rb +1 -1
- data/lib/applitools/selenium/match_window_task.rb +25 -18
- data/lib/applitools/selenium/mouse.rb +3 -3
- data/lib/applitools/selenium/viewport_size.rb +57 -48
- data/lib/applitools/utils/image_delta_compressor.rb +148 -150
- data/lib/applitools/utils/image_utils.rb +36 -3
- data/lib/applitools/utils/utils.rb +3 -6
- data/lib/applitools/version.rb +1 -1
- data/lib/eyes_selenium.rb +2 -2
- data/spec/driver_passthrough_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -5
- data/test/appium_example_script.rb +15 -15
- data/test/test_script.rb +1 -1
- data/test/watir_test_script.rb +1 -1
- metadata +23 -4
@@ -2,6 +2,8 @@ require 'oily_png'
|
|
2
2
|
require 'base64'
|
3
3
|
|
4
4
|
module Applitools::Utils
|
5
|
+
QUADRANTS_COUNT = 4.freeze
|
6
|
+
|
5
7
|
module ImageUtils
|
6
8
|
extend self
|
7
9
|
|
@@ -52,9 +54,40 @@ module Applitools::Utils
|
|
52
54
|
# and negative values are used for counter-clockwise rotation.
|
53
55
|
#
|
54
56
|
def quadrant_rotate!(image, num_quadrants)
|
55
|
-
|
56
|
-
|
57
|
-
|
57
|
+
num_quadrants %= QUADRANTS_COUNT
|
58
|
+
|
59
|
+
case num_quadrants
|
60
|
+
when 0
|
61
|
+
image
|
62
|
+
when 1
|
63
|
+
image.rotate_right!
|
64
|
+
when 2
|
65
|
+
image.rotate_180!
|
66
|
+
when 3
|
67
|
+
image.rotate_left!
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def scale!(image, factor)
|
72
|
+
image.resample_nearest_neighbor!(image.width.to_f * factor, image.height.to_f * factor)
|
73
|
+
end
|
74
|
+
|
75
|
+
def stitch_images(size, images_data)
|
76
|
+
ChunkyPNG::Image.new(size.width, size.height, ChunkyPNG::Color::TRANSPARENT).tap do |res|
|
77
|
+
images_data.each do |image_data|
|
78
|
+
# Crop out of bounds images.
|
79
|
+
image = image_data.image
|
80
|
+
position = image_data.position
|
81
|
+
|
82
|
+
new_width = position.left + image.width > size.width ? size.width - position.left : image.width
|
83
|
+
new_height = position.top + image.height > size.height ? size.height - position.top : image.height
|
84
|
+
|
85
|
+
if new_width != image.width || new_height != image.height
|
86
|
+
image = image.crop(0, 0, new_width, new_height)
|
87
|
+
end
|
88
|
+
|
89
|
+
res.compose!(image, position.left, position.top)
|
90
|
+
end
|
58
91
|
end
|
59
92
|
end
|
60
93
|
|
@@ -4,7 +4,7 @@ module Applitools::Utils
|
|
4
4
|
extend self
|
5
5
|
|
6
6
|
def underscore(str)
|
7
|
-
str.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').tr('-', '_').downcase
|
7
|
+
str.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').gsub(/([a-z\d])([A-Z])/, '\1_\2').tr('-', '_').downcase
|
8
8
|
end
|
9
9
|
|
10
10
|
def uncapitalize(str)
|
@@ -39,14 +39,11 @@ module Applitools::Utils
|
|
39
39
|
def convert_hash_keys(value, method)
|
40
40
|
case value
|
41
41
|
when Array
|
42
|
-
value.map {|v| convert_hash_keys(v, method) }
|
42
|
+
value.map { |v| convert_hash_keys(v, method) }
|
43
43
|
when Hash
|
44
|
-
Hash[value.map {|k, v| [send(method, k.to_s).to_sym,
|
45
|
-
convert_hash_keys(v, method)]}]
|
44
|
+
Hash[value.map { |k, v| [send(method, k.to_s).to_sym, convert_hash_keys(v, method)] }]
|
46
45
|
else
|
47
46
|
value
|
48
47
|
end
|
49
48
|
end
|
50
49
|
end
|
51
|
-
|
52
|
-
|
data/lib/applitools/version.rb
CHANGED
data/lib/eyes_selenium.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Applitools
|
2
2
|
ROOT_DIR = File.join(File.dirname(File.expand_path(__FILE__)), 'applitools').freeze
|
3
3
|
|
4
|
-
Dir["#{ROOT_DIR}/*.rb"].each {|f| require f}
|
5
|
-
Dir["#{ROOT_DIR}/**/*.rb"].each {|f| require f}
|
4
|
+
Dir["#{ROOT_DIR}/*.rb"].each { |f| require f }
|
5
|
+
Dir["#{ROOT_DIR}/**/*.rb"].each { |f| require f }
|
6
6
|
|
7
7
|
class EyesError < StandardError; end
|
8
8
|
class EyesAbort < EyesError; end
|
@@ -9,7 +9,7 @@ describe 'passthrough methods' do
|
|
9
9
|
eyes.api_key = 'dummy_key'
|
10
10
|
|
11
11
|
@driver = eyes.open(app_name: 'Specs', test_name: example.metadata[:full_description],
|
12
|
-
viewport_size: {width: 800, height: 600}, driver: web_driver)
|
12
|
+
viewport_size: { width: 800, height: 600 }, driver: web_driver)
|
13
13
|
@driver.get static_file
|
14
14
|
end
|
15
15
|
|
data/spec/spec_helper.rb
CHANGED
@@ -3,11 +3,11 @@ require 'eyes_selenium'
|
|
3
3
|
RSpec.configure do |config|
|
4
4
|
config.before do
|
5
5
|
allow_any_instance_of(Applitools::Base::ServerConnector).to receive(:start_session) do
|
6
|
-
Applitools::Base::Session.new('dummy_id', 'dummy_url', true
|
6
|
+
Applitools::Base::Session.new('dummy_id', 'dummy_url', true)
|
7
7
|
end
|
8
8
|
|
9
9
|
allow_any_instance_of(Applitools::Base::ServerConnector).to receive(:stop_session) do
|
10
|
-
Applitools::Base::TestResults.new
|
10
|
+
Applitools::Base::TestResults.new
|
11
11
|
end
|
12
12
|
|
13
13
|
allow_any_instance_of(Applitools::Base::ServerConnector).to receive(:match_window) do
|
@@ -15,6 +15,3 @@ RSpec.configure do |config|
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
@@ -7,31 +7,31 @@ require 'appium_lib'
|
|
7
7
|
|
8
8
|
def android_caps
|
9
9
|
{
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
deviceName: 'Samsung Galaxy S4 Emulator',
|
11
|
+
platformName: 'Android',
|
12
|
+
platformVersion: 4.4,
|
13
|
+
app: ENV['ANDROID_NOTES_LIST_APP'],
|
14
|
+
appPackage: 'com.example.android.notepad',
|
15
|
+
appActivity: '.NotesList',
|
16
|
+
# orientation: 'landscape',
|
17
|
+
newCommandTimeout: 300
|
18
18
|
}
|
19
19
|
end
|
20
20
|
|
21
21
|
def ios_caps
|
22
22
|
{
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
deviceName: 'iPhone 6',
|
24
|
+
platformName: 'ios',
|
25
|
+
platformVersion: 8.3,
|
26
|
+
app: ENV['IOS_DEMO_APP'],
|
27
|
+
orientation: 'landscape',
|
28
|
+
newCommandTimeout: 300
|
29
29
|
}
|
30
30
|
end
|
31
31
|
|
32
32
|
def appium_opts
|
33
33
|
{
|
34
|
-
|
34
|
+
server_url: 'http://127.0.0.1:4723/wd/hub'
|
35
35
|
}
|
36
36
|
end
|
37
37
|
|
data/test/test_script.rb
CHANGED
@@ -9,7 +9,7 @@ eyes.log_handler = Logger.new(STDOUT)
|
|
9
9
|
begin
|
10
10
|
web_driver = Selenium::WebDriver.for :chrome
|
11
11
|
|
12
|
-
eyes.test(app_name: 'Ruby SDK', test_name: 'Applitools website test', viewport_size: {width: 900, height: 600},
|
12
|
+
eyes.test(app_name: 'Ruby SDK', test_name: 'Applitools website test', viewport_size: { width: 900, height: 600 },
|
13
13
|
driver: web_driver) do |driver|
|
14
14
|
driver.get 'http://www.applitools.com'
|
15
15
|
eyes.check_window('initial')
|
data/test/watir_test_script.rb
CHANGED
@@ -10,7 +10,7 @@ eyes.log_handler = Logger.new(STDOUT)
|
|
10
10
|
browser = Watir::Browser.new
|
11
11
|
|
12
12
|
begin
|
13
|
-
eyes.test(app_name: 'Ruby SDK', test_name: 'Applitools website test', viewport_size: {width: 900, height: 600},
|
13
|
+
eyes.test(app_name: 'Ruby SDK', test_name: 'Applitools website test', viewport_size: { width: 900, height: 600 },
|
14
14
|
driver: browser) do |driver|
|
15
15
|
driver.get 'http://www.applitools.com'
|
16
16
|
eyes.check_window('initial')
|
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.17.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: 2015-05-
|
11
|
+
date: 2015-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selenium-webdriver
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '1.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: faraday
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rubocop
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: pry
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -201,6 +215,7 @@ extra_rdoc_files: []
|
|
201
215
|
files:
|
202
216
|
- ".gitignore"
|
203
217
|
- ".rspec"
|
218
|
+
- ".rubocop.yml"
|
204
219
|
- ".travis.yml"
|
205
220
|
- Gemfile
|
206
221
|
- LICENSE.txt
|
@@ -211,6 +226,7 @@ files:
|
|
211
226
|
- lib/applitools/base/batch_info.rb
|
212
227
|
- lib/applitools/base/dimension.rb
|
213
228
|
- lib/applitools/base/environment.rb
|
229
|
+
- lib/applitools/base/image_position.rb
|
214
230
|
- lib/applitools/base/mouse_trigger.rb
|
215
231
|
- lib/applitools/base/point.rb
|
216
232
|
- lib/applitools/base/region.rb
|
@@ -219,9 +235,11 @@ files:
|
|
219
235
|
- lib/applitools/base/start_info.rb
|
220
236
|
- lib/applitools/base/test_results.rb
|
221
237
|
- lib/applitools/base/text_trigger.rb
|
238
|
+
- lib/applitools/extensions.rb
|
222
239
|
- lib/applitools/eyes.rb
|
223
240
|
- lib/applitools/eyes_logger.rb
|
224
241
|
- lib/applitools/method_tracer.rb
|
242
|
+
- lib/applitools/selenium/browser.rb
|
225
243
|
- lib/applitools/selenium/driver.rb
|
226
244
|
- lib/applitools/selenium/element.rb
|
227
245
|
- lib/applitools/selenium/keyboard.rb
|
@@ -271,3 +289,4 @@ test_files:
|
|
271
289
|
- test/appium_example_script.rb
|
272
290
|
- test/test_script.rb
|
273
291
|
- test/watir_test_script.rb
|
292
|
+
has_rdoc:
|