eyes_core 4.5.0.alpha → 4.5.0

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: 9c7a7954467752a70c0d4f461440fd757e5152569db10f88268e13b63a287982
4
- data.tar.gz: '08eb391d5a2aa367873fe596c9adedfafaf195cec3cc70fc4203f303d083ae02'
3
+ metadata.gz: 2d45209c9c24fc6195bd5976553685c728e7fc63ee51ff4e7aab235d2e7377b9
4
+ data.tar.gz: a4a3a767883ef42d42edc9aa5ffa4ed24560750d8d71220cfa4002ae3e309169
5
5
  SHA512:
6
- metadata.gz: d0089cdebd1f02bb2e721ead00c0e321a334e79a0db516d45ad7a2b7d65f1862cb232d1a716212bc867eeda45fe4088b1e033bcc72531f6ff9b19a9c51699034
7
- data.tar.gz: 9840236d2db173ba8c903fc495e0e332743483c36be2c5f8a59293b86c5514f23e2315b880eb4eefd43693fac3f8e585e1436bf3b276ff7f31c8635f99176494
6
+ metadata.gz: ca8ba2d682a80135d4bd164310910b09baa5cf3e0adc678656d9504465e08da88369563171880f044896ab7a09d70ab18f762e5fa5d1c5ccf21e3e503ad5d21a
7
+ data.tar.gz: 355720cbdde598cc88dd94f9e1a4efea5401c4cb261f21e53a8cbd3f4492f65c3dbb41fb0f04390708b8d3cc7cb0629dbcd658155a4a36de3c85b9c186945ae4
@@ -8,11 +8,12 @@ module Applitools
8
8
  LAYOUT1 = 'Layout1'.freeze
9
9
  LAYOUT2 = 'Layout2'.freeze
10
10
  CONTENT = 'Content'.freeze
11
+ IGNORE_COLORS = 'IgnoreColors'.freeze
11
12
  STRICT = 'Strict'.freeze
12
13
  EXACT = 'Exact'.freeze
13
14
 
14
15
  def enum_values
15
- [NONE, LAYOUT, LAYOUT1, LAYOUT2, CONTENT, STRICT, EXACT]
16
+ [NONE, LAYOUT, LAYOUT1, LAYOUT2, CONTENT, IGNORE_COLORS, STRICT, EXACT]
16
17
  end
17
18
  end
18
19
  end
@@ -13,9 +13,11 @@ module Applitools
13
13
 
14
14
  raise Applitools::EyesNotOpenException.new('Eyes not open!') if @universal_eyes.nil?
15
15
  Applitools::EyesLogger.logger.info "#{test_name} : check(#{name}) started ..."
16
+ settings = get_universal_check_settings(name, target)
17
+ image_target = settings[:image].nil? ? {} : { image: settings.delete(:image) }
16
18
  # require 'pry'
17
19
  # binding.pry
18
- check_result = @universal_eyes.check(get_universal_check_settings(name, target))
20
+ check_result = @universal_eyes.check(settings, image_target)
19
21
  if server_error?(check_result)
20
22
  # require 'pry'
21
23
  # binding.pry
@@ -29,6 +31,7 @@ module Applitools
29
31
  end
30
32
 
31
33
  logger.info 'Done!'
34
+ result
32
35
  end
33
36
 
34
37
  private
@@ -18,17 +18,19 @@ module Applitools
18
18
  # trigger recording and frame handling
19
19
  def universal_open(options = {})
20
20
  original_driver = options.delete(:driver)
21
- Applitools::ArgumentGuard.not_nil original_driver, 'options[:driver]'
21
+ if self.class.name != 'Applitools::Images::Eyes'
22
+ Applitools::ArgumentGuard.not_nil original_driver, 'options[:driver]'
22
23
 
23
- if respond_to?(:disabled?) && disabled?
24
- logger.info('Ignored')
25
- return original_driver
26
- end
24
+ if respond_to?(:disabled?) && disabled?
25
+ logger.info('Ignored')
26
+ return original_driver
27
+ end
27
28
 
28
- self.driver = Applitools::Selenium::SeleniumEyes.eyes_driver(original_driver, self)
29
+ self.driver = Applitools::Selenium::SeleniumEyes.eyes_driver(original_driver, self)
30
+ end
29
31
 
30
32
  update_config_from_options(options)
31
- universal_driver_config = driver.universal_driver_config
33
+ universal_driver_config = driver.universal_driver_config if self.class.name != 'Applitools::Images::Eyes'
32
34
  universal_eyes_manager = runner.get_universal_eyes_manager
33
35
 
34
36
  universal_eyes_config = Applitools::UniversalEyesConfig.new
@@ -42,7 +44,11 @@ module Applitools
42
44
 
43
45
  self.open = true if respond_to?(:open=, true)
44
46
  self.running_session = true if respond_to?(:running_session=, true)
45
- driver
47
+ if self.class.name != 'Applitools::Images::Eyes'
48
+ driver
49
+ else
50
+ self.open?
51
+ end
46
52
  rescue Applitools::EyesError => e
47
53
  logger.error e.message
48
54
  raise e
@@ -9,7 +9,9 @@ module Applitools
9
9
  # minMatch?: number
10
10
  # language?: string
11
11
  # }
12
- def extract_text(targets_array)
12
+ def extract_text(*args)
13
+ image_target = args[0].is_a?(Hash) ? args[0] : nil
14
+ targets_array = args[0].is_a?(Hash) ? args[1].to_a : args[0]
13
15
  targets_array.map do |target|
14
16
  target['target'] = { elementId: target['target'].ref } if target['target'].is_a?(::Selenium::WebDriver::Element)
15
17
  target['target']['x'] = target['target'].delete('left') if target['target']['left']
@@ -17,7 +19,7 @@ module Applitools
17
19
  target[:region] = target.delete('target')
18
20
  target
19
21
  end
20
- driver_target = driver.universal_driver_config
22
+ driver_target = respond_to?(:driver) ? driver.universal_driver_config : image_target
21
23
  universal_eyes.extract_text(targets_array, driver_target)
22
24
  end
23
25
 
@@ -29,7 +31,7 @@ module Applitools
29
31
  # language?: string
30
32
  # }
31
33
  def extract_text_regions(patterns_array)
32
- driver_target = driver.universal_driver_config
34
+ driver_target = respond_to?(:driver) ? driver.universal_driver_config : { image: patterns_array.delete('image') }
33
35
  results = universal_eyes.extract_text_regions(patterns_array, driver_target)
34
36
  Applitools::Utils.deep_stringify_keys(results)
35
37
  end
@@ -84,6 +84,15 @@ module Applitools
84
84
  json_fields :ufgOptions,
85
85
  :userCommandId
86
86
 
87
+ # ImageTarget
88
+ json_fields :image
89
+ # :name,
90
+ # :source,
91
+ # :dom,
92
+ # :locationInViewport,
93
+ # :locationInView,
94
+ # :fullViewSize
95
+
87
96
  def initialize(*args)
88
97
  options = Applitools::Utils.extract_options! args
89
98
  options.keys.select {|k| options[k] && respond_to?("#{k}=") }.each {|k| send("#{k}=", options[k]) }
@@ -104,6 +113,7 @@ module Applitools
104
113
  def from_original_target(target, eyes)
105
114
  # require('pry')
106
115
  # binding.pry
116
+ return from_eyes_images(target, eyes) if eyes.class.name === 'Applitools::Images::Eyes'
107
117
 
108
118
  self.accessibility_settings = eyes.accessibility_validation
109
119
  self.disable_browser_fetching = eyes.dont_fetch_resources
@@ -166,11 +176,37 @@ module Applitools
166
176
  self.visual_grid_options = from_target_options_or_eyes(:visual_grid_options, target.options, eyes)
167
177
  self.ufg_options = self.visual_grid_options
168
178
  self.user_command_id = self.variation_group_id
179
+
180
+ self.image = target.image if target.respond_to?(:image)
169
181
  # rescue => e
170
182
  # require('pry')
171
183
  # binding.pry
172
184
  end
173
185
 
186
+ def from_eyes_images(target, eyes)
187
+ self.accessibility_settings = eyes.accessibility_validation
188
+ self.disable_browser_fetching = eyes.dont_fetch_resources
189
+ self.accessibility_regions = target.accessibility_regions
190
+ self.floating_regions = target.floating_regions
191
+
192
+ self.ignore_regions = target.ignored_regions.map do |ir|
193
+ ir.is_a?(Proc) ? normalize_element_selector(ir.call(eyes.driver)) : ir
194
+ end
195
+
196
+ if target.region_to_check.is_a?(Hash)
197
+ self.region = target.region_to_check
198
+ elsif target.region_to_check.is_a?(String)
199
+ self.region = target.region_to_check
200
+ elsif target.region_to_check.is_a?(Proc)
201
+ el = target.region_to_check.call(eyes.driver)
202
+ self.region = normalize_element_selector(el) unless el.respond_to?(:empty?) && el.empty?
203
+ end
204
+
205
+ self.exact = (target.options[:exact] && target.options[:exact].to_hash) || (eyes.exact && eyes.exact.to_hash)
206
+
207
+ self.image = target.image
208
+ end
209
+
174
210
  def to_hash
175
211
  json_data.compact.reject do |_, v|
176
212
  case v
@@ -157,7 +157,7 @@ module Applitools::Connectivity
157
157
  command_with_result(EYES_MANAGER_CLOSE_ALL_EYES, {manager: manager, config: commands_config})
158
158
  end
159
159
 
160
- def eyes_check(eyes, settings)
160
+ def eyes_check(eyes, settings, image_target = {})
161
161
  # interface CheckRequestPayload {
162
162
  # eyes: Ref<Eyes>
163
163
  # target?: ImageTarget | DriverTarget
@@ -166,7 +166,9 @@ module Applitools::Connectivity
166
166
  # }
167
167
  #
168
168
  # type CheckResponsePayload = CheckResult[]
169
- command_with_result(EYES_CHECK, {eyes: eyes, settings: settings, config: commands_config})
169
+ payload = {eyes: eyes, settings: settings, config: commands_config}
170
+ payload[:target] = image_target unless image_target.empty?
171
+ command_with_result(EYES_CHECK, payload)
170
172
  end
171
173
 
172
174
  def eyes_locate(eyes, settings, driver_target)
@@ -192,7 +194,9 @@ module Applitools::Connectivity
192
194
  # }
193
195
  #
194
196
  # type LocateTextResponcePayload = Record<string, Array<{text: string, x: number, y: number, width: number, hieght: number}>>
195
- command_with_result(EYES_EXTRACT_TEXT_REGIONS, {eyes: eyes, settings: settings, config: commands_config})
197
+ payload = {eyes: eyes, target: driver_target, settings: settings, config: commands_config}
198
+ payload.delete(:target) if driver_target.nil? || driver_target.empty?
199
+ command_with_result(EYES_EXTRACT_TEXT_REGIONS, payload)
196
200
  end
197
201
 
198
202
  def eyes_extract_text(eyes, regions, driver_target)
@@ -204,7 +208,9 @@ module Applitools::Connectivity
204
208
  # }
205
209
  #
206
210
  # type ExtractTextResponcePayload = string[]
207
- command_with_result(EYES_EXTRACT_TEXT, {eyes: eyes, settings: regions, config: commands_config})
211
+ payload = {eyes: eyes, target: driver_target, settings: regions, config: commands_config}
212
+ payload.delete(:settings) if regions.empty?
213
+ command_with_result(EYES_EXTRACT_TEXT, payload)
208
214
  end
209
215
 
210
216
  def eyes_close(eyes)
@@ -11,10 +11,10 @@ module Applitools
11
11
  @universal_client = universal_client
12
12
  end
13
13
 
14
- def check(settings)
14
+ def check(settings, image_target = {})
15
15
  elapsed_time_start = Time.now
16
16
  # Applitools::EyesLogger.logger.debug "check settings: #{settings}"
17
- check_result = @universal_client.eyes_check(@eyes, settings)
17
+ check_result = @universal_client.eyes_check(@eyes, settings, image_target)
18
18
  # Applitools::EyesLogger.logger.debug "check_result: #{check_result}"
19
19
  Applitools::EyesLogger.logger.info "Completed in #{format('%.2f', Time.now - elapsed_time_start)} seconds"
20
20
  check_result
@@ -166,8 +166,27 @@ module Applitools
166
166
  end
167
167
  end
168
168
 
169
+ def from_eyes_images
170
+ FROM_ORIGINAL_EYES - [
171
+ :browsers_info,
172
+ :concurrent_sessions,
173
+ :debug_screenshots,
174
+ :force_full_page_screenshot,
175
+ :hide_caret,
176
+ :hide_scrollbars,
177
+ :send_dom,
178
+ :stitch_mode,
179
+ :visual_grid_options,
180
+ :wait_before_screenshots,
181
+ :wait_before_capture,
182
+ :stitching_overlap
183
+ ]
184
+
185
+ end
186
+
169
187
  def from_original_sdk(original_eyes)
170
- FROM_ORIGINAL_EYES.each {|m| copy_from(m, original_eyes) }
188
+ from_eyes = original_eyes.class.name != 'Applitools::Images::Eyes' ? FROM_ORIGINAL_EYES : from_eyes_images
189
+ from_eyes.each {|m| copy_from(m, original_eyes) }
171
190
  self.agent_id = original_eyes.base_agent_id if original_eyes.respond_to?(:base_agent_id)
172
191
  self.agent_id = original_eyes.full_agent_id if original_eyes.respond_to?(:full_agent_id)
173
192
  # self.display_name = original_eyes.app_name
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Applitools
4
- VERSION = '4.5.0.alpha'.freeze
4
+ VERSION = '4.5.0'.freeze
5
+ IMAGES_VERSION = '4.0.0'.freeze
5
6
  UNIVERSAL_VERSION = '3.0.2'.freeze
6
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eyes_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.0.alpha
4
+ version: 4.5.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: 2022-11-23 00:00:00.000000000 Z
11
+ date: 2022-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -422,9 +422,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
422
422
  version: '0'
423
423
  required_rubygems_version: !ruby/object:Gem::Requirement
424
424
  requirements:
425
- - - ">"
425
+ - - ">="
426
426
  - !ruby/object:Gem::Version
427
- version: 1.3.1
427
+ version: '0'
428
428
  requirements: []
429
429
  rubygems_version: 3.3.14
430
430
  signing_key: