eyes_selenium 3.17.2 → 3.17.7

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
  SHA256:
3
- metadata.gz: 8bbe944af9ea20d3d0afde5ae4e96b6b33d42e4e171e4bfb1d4dc0a4866e1056
4
- data.tar.gz: 1cfc9ec471f9f02944189c0e442c59530e8ea37e8a586e04128191ef401316ed
3
+ metadata.gz: d1e1cc6d5f14b8764c463018f3f808431682bb3cb7feedacc1c4d078c8bf2856
4
+ data.tar.gz: 695298fd561d6c9a9736f16358135a3805417e18190daf6d9e349d47cc18a9db
5
5
  SHA512:
6
- metadata.gz: d6e40409125ded5b69be42f291a23a7dc61b61c54420eaaa5ca397b279e8d4b33931b446ffdd2f03c20a28ebd73dfc2d9d9c21dd6fd8e65e81707f649d574c50
7
- data.tar.gz: abd633ddeaef17adf5f937c00a149956b4b5587356bc2ec5467e88e4374f99716b47f7e964f35a1553776a5ac0e36267e51df947f7c8c05c365b874c31f496e1
6
+ metadata.gz: ac8f4829d35af73da8fbd52bf3fec733d8231575d8c8721c9fffc9ae23a22fcc3af3ddce45f90c0ec024dfb2202ac3bcb59201bcc54bcde3c60894e1618080bc
7
+ data.tar.gz: 02ba588e928af04592b2bdffa57be76adc4c19d235d63649e82f3fc46e707fa4afa8fff65665e2aee77c8e49a3da2c8c3a88972be0edea01b77d154f3fad1693
@@ -1,5 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
  module BrowserTypes
3
+ extend self
4
+ def const_missing(name)
5
+ puts 'Please, prefer using BrowserType instead of BrowserTypes(plural).'
6
+ BrowserType.const_get(name)
7
+ end
8
+
9
+ def enum_values
10
+ BrowserType.enum_values
11
+ end
12
+ end
13
+ module BrowserType
3
14
  extend self
4
15
  CHROME = :'chrome-0'
5
16
  CHROME_ONE_VERSION_BACK = :'chrome-1'
@@ -1,5 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
  module Orientations
3
+ extend self
4
+ def const_missing(name)
5
+ puts 'Please prefer using the Orientation instead of Orientations(plural).'
6
+ Orientation.const_get(name)
7
+ end
8
+ def enum_values
9
+ Orientation.enum_values
10
+ end
11
+ end
12
+
13
+ module Orientation
3
14
  extend self
4
15
  PORTRAIT = 'portrait'
5
16
  LANDSCAPE = 'landscape'
@@ -21,7 +21,7 @@ module Applitools
21
21
 
22
22
  attr_accessor :element, :frames, :region_to_check, :coordinate_type, :options, :ignored_regions,
23
23
  :floating_regions, :frame_or_element, :regions, :layout_regions, :content_regions,
24
- :strict_regions, :accessibility_regions
24
+ :strict_regions, :accessibility_regions, :convert_coordinates_block
25
25
 
26
26
  private :frame_or_element, :frame_or_element=
27
27
 
@@ -33,6 +33,7 @@ module Applitools
33
33
  script_hooks: { beforeCaptureScreenshot: '' }
34
34
  }
35
35
  self.regions = {}
36
+ self.convert_coordinates_block = nil
36
37
  reset_for_fullscreen
37
38
  end
38
39
 
@@ -374,6 +375,10 @@ module Applitools
374
375
  nil
375
376
  end
376
377
 
378
+ def convert_coordinates(&block)
379
+ self.convert_coordinates_block = block
380
+ end
381
+
377
382
  private
378
383
 
379
384
  def reset_for_fullscreen
@@ -7,7 +7,7 @@ module Applitools
7
7
  DEFAULT_CONFIG = proc do
8
8
  {
9
9
  platform: 'linux',
10
- browser_type: BrowserTypes::CHROME,
10
+ browser_type: BrowserType::CHROME,
11
11
  # size_mode: 'full-page',
12
12
  viewport_size: Applitools::RectangleSize.from_any_argument(width: 0, height: 0)
13
13
  }
@@ -18,22 +18,40 @@ module Applitools
18
18
  end
19
19
  end
20
20
 
21
+ object_field :emulation_info, Applitools::Selenium::EmulationBaseInfo
22
+
23
+ # def device_name
24
+ # emulation_info.device_name
25
+ # end
26
+ #
21
27
  def initialize(*args)
22
- super()
28
+ options = Applitools::Utils.extract_options!(args.dup)
29
+ super(options)
23
30
  case args[0]
24
31
  when String
25
32
  self.emulation_info = EmulationInfo.new.tap do |ei|
26
33
  ei.device_name = args[0]
27
- ei.screen_orientation = args[1] || Orientations::PORTRAIT
34
+ ei.screen_orientation = args[1] || Orientation::PORTRAIT
28
35
  end
29
36
  when Hash
30
37
  self.emulation_info = EmulationInfo.new.tap do |ei|
31
38
  ei.device_name = args[0][:device_name]
32
- ei.screen_orientation = args[0][:screen_orientation] || Orientations::PORTRAIT
39
+ ei.screen_orientation = args[0][:screen_orientation] || Orientation::PORTRAIT
33
40
  end
41
+ else
42
+ raise Applitools::EyesIllegalArgument, 'You should pass :device_name and :screen_orientation'
34
43
  end
35
44
  end
36
45
 
46
+ def to_s
47
+ "#{emulation_info.device_name} - #{emulation_info.screen_orientation}"
48
+ end
49
+
50
+ def device_name
51
+ emulation_info.device_name + ' (chrome emulation)'
52
+ end
53
+
54
+
37
55
  private
38
56
 
39
57
  class EmulationInfo < Applitools::Selenium::EmulationBaseInfo
@@ -7,7 +7,7 @@ module Applitools
7
7
  DEFAULT_CONFIG = proc do
8
8
  {
9
9
  platform: 'linux',
10
- browser_type: BrowserTypes::CHROME,
10
+ browser_type: BrowserType::CHROME,
11
11
  # size_mode: 'full-page',
12
12
  viewport_size: Applitools::RectangleSize.from_any_argument(width: 0, height: 0)
13
13
  }
@@ -20,7 +20,7 @@ module Applitools
20
20
  end
21
21
 
22
22
  def initialize(options = {})
23
- super()
23
+ super
24
24
  if options[:width] && options[:height]
25
25
  self.viewport_size = Applitools::RectangleSize.from_any_argument(width: options[:width], height: options[:height])
26
26
  end
@@ -29,15 +29,17 @@ module Applitools
29
29
 
30
30
  def platform
31
31
  case browser_type
32
- when BrowserTypes::EDGE_LEGACY, BrowserTypes::EDGE_CHROMIUM, BrowserTypes::EDGE_CHROMIUM_ONE_VERSION_BACK
32
+ when BrowserType::EDGE_LEGACY, BrowserType::EDGE_CHROMIUM, BrowserType::EDGE_CHROMIUM_ONE_VERSION_BACK
33
33
  'windows'
34
34
  else
35
35
  'linux'
36
36
  end
37
37
  end
38
38
 
39
+ def device_name
40
+ 'desktop'
41
+ end
42
+
39
43
  end
40
44
  end
41
45
  end
42
-
43
- Applitools::Selenium::RenderBrowserInfo = Applitools::Selenium::DesktopBrowserInfo
@@ -30,7 +30,7 @@ module Applitools
30
30
  def open(driver, browser_info)
31
31
  self.driver = driver
32
32
  self.browser_info = browser_info
33
- self.device_name = browser_info && browser_info.emulation_info && browser_info.emulation_info.device_name
33
+ self.device_name = browser_info.device_name
34
34
  logger.info "opening EyesConnector for #{config.short_description} with viewport size: #{browser_info}"
35
35
  config.viewport_size = browser_info.viewport_size
36
36
  title
@@ -54,7 +54,6 @@ module Applitools
54
54
  logger.error "Error retrieving coordinates for region #{e.region}"
55
55
  logger.error e.message
56
56
  end
57
-
58
57
  check_result = check_window_base(
59
58
  dummy_region_provider, timeout, match_data
60
59
  )
@@ -3,16 +3,18 @@ module Applitools
3
3
  class IRenderBrowserInfo < ::Applitools::AbstractConfiguration
4
4
 
5
5
  object_field :viewport_size, Applitools::RectangleSize
6
- enum_field :browser_type, BrowserTypes.enum_values
6
+ enum_field :browser_type, BrowserType.enum_values
7
7
  string_field :platform
8
8
  string_field :size_mode
9
9
  string_field :baseline_env_name
10
- object_field :emulation_info, Applitools::Selenium::EmulationBaseInfo
11
- object_field :ios_device_info, Applitools::Selenium::EmulationBaseInfo
10
+
11
+ def initialize(options = {})
12
+ super()
13
+ self.baseline_env_name = options[:baseline_env_name] if options[:baseline_env_name]
14
+ end
12
15
 
13
16
  def to_s
14
- return "#{viewport_size} (#{browser_type})" unless emulation_info
15
- "#{emulation_info.device_name} - #{emulation_info.screen_orientation}"
17
+ return "#{viewport_size} (#{browser_type})"
16
18
  end
17
19
  end
18
20
  end
@@ -11,26 +11,36 @@ module Applitools
11
11
  viewport_size: Applitools::RectangleSize.from_any_argument(width: 0, height: 0)
12
12
  }
13
13
  end
14
+
15
+ object_field :ios_device_info, Applitools::Selenium::EmulationBaseInfo
16
+
14
17
  class << self
15
18
  def default_config
16
19
  DEFAULT_CONFIG.call
17
20
  end
18
21
  end
19
22
 
20
-
21
23
  def initialize(options = {})
22
- super()
24
+ super
23
25
  self.ios_device_info = EmulationInfo.new.tap do |ei|
24
26
  ei.device_name = options[:device_name]
25
- ei.screen_orientation = options[:screen_orientation] || IosScreenshotOrientations::PORTRAIT
27
+ ei.screen_orientation = options[:screen_orientation] || options[:orientation] || IosScreenOrientation::PORTRAIT
26
28
  end
27
29
  end
28
30
 
31
+ def to_s
32
+ "#{ios_device_info.device_name} - #{ios_device_info.screen_orientation}"
33
+ end
34
+
35
+ def device_name
36
+ ios_device_info.device_name
37
+ end
38
+
29
39
  private
30
40
 
31
41
  class EmulationInfo < EmulationBaseInfo
32
42
  enum_field :device_name, IosDeviceName.enum_values
33
- enum_field :screen_orientation, IosScreenshotOrientations.enum_values
43
+ enum_field :screen_orientation, IosScreenOrientation.enum_values
34
44
 
35
45
  def json_data
36
46
  {
@@ -1,4 +1,4 @@
1
- module IosScreenshotOrientations
1
+ module IosScreenOrientation
2
2
  extend self
3
3
  PORTRAIT ='portrait'
4
4
  LANDSCAPE_LEFT = 'landscapeLeft'
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+ require 'applitools/selenium/browser_types'
3
+ # We should not break the API
4
+ module Applitools
5
+ module Selenium
6
+ class RenderBrowserInfo < IRenderBrowserInfo
7
+ DEFAULT_CONFIG = proc do
8
+ {
9
+ platform: 'linux',
10
+ browser_type: BrowserTypes::CHROME,
11
+ # size_mode: 'full-page',
12
+ viewport_size: Applitools::RectangleSize.from_any_argument(width: 0, height: 0)
13
+ }
14
+ end
15
+
16
+ object_field :ios_device_info, Applitools::Selenium::EmulationBaseInfo
17
+ object_field :emulation_info, Applitools::Selenium::EmulationBaseInfo
18
+
19
+ class << self
20
+ def default_config
21
+ DEFAULT_CONFIG.call
22
+ end
23
+ end
24
+
25
+ def initialize(options = {})
26
+ super
27
+ if options[:width] && options[:height]
28
+ self.viewport_size = Applitools::RectangleSize.from_any_argument(width: options[:width], height: options[:height])
29
+ end
30
+ self.browser_type = options[:browser_type] if options[:browser_type]
31
+ end
32
+
33
+ def platform
34
+ return 'ios' if ios_device_info
35
+ case browser_type
36
+ when BrowserType::EDGE_LEGACY, BrowserType::EDGE_CHROMIUM, BrowserType::EDGE_CHROMIUM_ONE_VERSION_BACK
37
+ 'windows'
38
+ else
39
+ 'linux'
40
+ end
41
+ end
42
+
43
+ def to_s
44
+ if emulation_info
45
+ "#{emulation_info.device_name} - #{emulation_info.screen_orientation}"
46
+ elsif ios_device_info
47
+ "#{ios_device_info.device_name} - #{ios_device_info.screen_orientation}"
48
+ end
49
+ "#{viewport_size} (#{browser_type})"
50
+ end
51
+
52
+ def device_name
53
+ if ios_device_info
54
+ return ios_device_info.device_name
55
+ elsif emulation_info
56
+ return emulation_info.device_name + ' (chrome emulation)'
57
+ end
58
+ 'desktop'
59
+ end
60
+ end
61
+ end
62
+ end
@@ -248,8 +248,11 @@ module Applitools
248
248
  r.height = running_test.browser_info.viewport_size.height
249
249
  r.size_mode = size_mode
250
250
  r.region = region_to_check
251
- r.emulation_info = running_test.browser_info.emulation_info if running_test.browser_info.emulation_info
252
- r.ios_device_info = running_test.browser_info.ios_device_info if running_test.browser_info.ios_device_info
251
+ if running_test.browser_info.respond_to?(:emulation_info) && running_test.browser_info.emulation_info
252
+ r.emulation_info = running_test.browser_info.emulation_info
253
+ elsif running_test.browser_info.respond_to?(:ios_device_info) && running_test.browser_info.ios_device_info
254
+ r.ios_device_info = running_test.browser_info.ios_device_info
255
+ end
253
256
  end
254
257
 
255
258
  requests << Applitools::Selenium::RenderRequest.new(
@@ -3,6 +3,15 @@
3
3
  module Applitools
4
4
  module Selenium
5
5
  class VgMatchWindowData < Applitools::MatchWindowData
6
+ CONVERT_COORDINATES = proc do |region, selector_regions|
7
+ begin
8
+ offset_region = selector_regions.last
9
+ new_location = region.location.offset_negative(Applitools::Location.new(offset_region['x'].to_i, offset_region['y'].to_i))
10
+ region.location = new_location
11
+ rescue
12
+ Applitools::EyesLogger.error("Failed to convert coordinates for #{region}")
13
+ end
14
+ end
6
15
  class RegionCoordinatesError < ::Applitools::EyesError
7
16
  attr_accessor :region
8
17
  def initialize(region, message)
@@ -109,7 +118,11 @@ module Applitools
109
118
  region = selector_regions[target.regions[region]]
110
119
  raise RegionCoordinatesError.new(r, region['error']) if region['error']
111
120
  retrieved_region = Applitools::Region.new(region['x'], region['y'], region['width'], region['height'])
112
- result_region = r.padding_proc.call(retrieved_region) if r.padding_proc.is_a? Proc
121
+ result_region = if r.padding_proc.is_a? Proc
122
+ r.padding_proc.call(retrieved_region)
123
+ else
124
+ retrieved_region
125
+ end
113
126
  result << result_region
114
127
  end
115
128
  end
@@ -118,36 +131,54 @@ module Applitools
118
131
 
119
132
  def convert_ignored_regions_coordinates
120
133
  return unless @need_convert_ignored_regions_coordinates
134
+ if target.convert_coordinates_block.is_a?(Proc)
135
+ @ignored_regions.each { |r| target.convert_coordinates_block.call(r, selector_regions)}
136
+ end
121
137
  self.ignored_regions = @ignored_regions.map(&:with_padding).map(&:to_hash)
122
138
  @need_convert_ignored_regions_coordinates = false
123
139
  end
124
140
 
125
141
  def convert_floating_regions_coordinates
126
142
  return unless @need_convert_floating_regions_coordinates
143
+ if target.convert_coordinates_block.is_a?(Proc)
144
+ @floating_regions.each { |r| target.convert_coordinates_block.call(r, selector_regions)}
145
+ end
127
146
  self.floating_regions = @floating_regions
128
147
  @need_convert_floating_regions_coordinates = false
129
148
  end
130
149
 
131
150
  def convert_layout_regions_coordinates
132
151
  return unless @need_convert_layout_regions_coordinates
152
+ if target.convert_coordinates_block.is_a?(Proc)
153
+ @layout_regions.each { |r| target.convert_coordinates_block.call(r, selector_regions)}
154
+ end
133
155
  self.layout_regions = @layout_regions
134
156
  @need_convert_layout_regions_coordinates = false
135
157
  end
136
158
 
137
159
  def convert_strict_regions_coordinates
138
160
  return unless @need_convert_strict_regions_coordinates
161
+ if target.convert_coordinates_block.is_a?(Proc)
162
+ @strict_regions.each { |r| target.convert_coordinates_block.call(r, selector_regions)}
163
+ end
139
164
  self.strict_regions = @strict_regions
140
165
  @need_convert_strict_regions_coordinates = false
141
166
  end
142
167
 
143
168
  def convert_content_regions_coordinates
144
169
  return unless @need_convert_content_regions_coordinates
170
+ if target.convert_coordinates_block.is_a?(Proc)
171
+ @content_regions.each { |r| target.convert_coordinates_block.call(r, selector_regions)}
172
+ end
145
173
  self.content_regions = @content_regions
146
174
  @need_convert_content_regions_coordinates = false
147
175
  end
148
176
 
149
177
  def convert_accessibility_regions_coordinates
150
178
  return unless @need_convert_accessibility_regions_coordinates
179
+ if target.convert_coordinates_block.is_a?(Proc)
180
+ @accessibility_regions.each { |r| target.convert_coordinates_block.call(r, selector_regions)}
181
+ end
151
182
  self.accessibility_regions = @accessibility_regions
152
183
  @need_convert_accessibility_regions_coordinates = false
153
184
  end
@@ -154,6 +154,7 @@ module Applitools
154
154
  mod = Digest::SHA2.hexdigest(script_thread_result[:script_result])
155
155
 
156
156
  region_x_paths = get_regions_x_paths(target_to_check)
157
+
157
158
  render_task = RenderTask.new(
158
159
  "Render #{config.short_description} - #{tag}",
159
160
  script_thread_result[:result]['value'],
@@ -169,6 +170,10 @@ module Applitools
169
170
  )
170
171
  end
171
172
 
173
+ if size_mod == 'selector'
174
+ target_to_check.convert_coordinates(&Applitools::Selenium::VgMatchWindowData::CONVERT_COORDINATES)
175
+ end
176
+
172
177
  title = begin
173
178
  driver.title
174
179
  rescue StandardError => e
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Applitools
4
- VERSION = '3.17.2'.freeze
4
+ VERSION = '3.17.7'.freeze
5
5
  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: 3.17.2
4
+ version: 3.17.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Applitools Team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-05 00:00:00.000000000 Z
11
+ date: 2020-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eyes_core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.17.2
19
+ version: 3.17.7
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 3.17.2
26
+ version: 3.17.7
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: selenium-webdriver
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -157,6 +157,7 @@ files:
157
157
  - lib/applitools/selenium/visual_grid/ios_device_info.rb
158
158
  - lib/applitools/selenium/visual_grid/ios_device_name.rb
159
159
  - lib/applitools/selenium/visual_grid/ios_screen_orientation.rb
160
+ - lib/applitools/selenium/visual_grid/render_browser_info.rb
160
161
  - lib/applitools/selenium/visual_grid/render_info.rb
161
162
  - lib/applitools/selenium/visual_grid/render_request.rb
162
163
  - lib/applitools/selenium/visual_grid/render_requests.rb
@@ -177,7 +178,7 @@ homepage: https://www.applitools.com
177
178
  licenses:
178
179
  - Applitools
179
180
  metadata: {}
180
- post_install_message:
181
+ post_install_message:
181
182
  rdoc_options: []
182
183
  require_paths:
183
184
  - lib
@@ -193,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
194
  version: '0'
194
195
  requirements: []
195
196
  rubygems_version: 3.0.8
196
- signing_key:
197
+ signing_key:
197
198
  specification_version: 4
198
199
  summary: Applitools Ruby Selenium SDK
199
200
  test_files: []