eyes_selenium 3.18.4 → 4.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -58,7 +58,8 @@ module Applitools
58
58
  end
59
59
 
60
60
  def init_or_renew_threads
61
- (concurrency - @thread_group.list.count).times do
61
+ one_concurrency = 1 # Thread's moved to universal server
62
+ (one_concurrency - @thread_group.list.count).times do
62
63
  logger.debug 'starting new thread (task worker)'
63
64
  next_thread
64
65
  end
@@ -7,6 +7,13 @@ require 'securerandom'
7
7
  module Applitools
8
8
  module Selenium
9
9
  class VisualGridEyes
10
+ # new open, with eyes-manager
11
+ include Applitools::UniversalEyesOpen
12
+ # all checks here
13
+ include Applitools::UniversalEyesChecks
14
+ # add extract_text, extract_text_regions, locate
15
+ include Applitools::UniversalNewApi
16
+
10
17
  include Applitools::Selenium::Concerns::SeleniumEyes
11
18
  USE_DEFAULT_MATCH_TIMEOUT = -1
12
19
  extend Forwardable
@@ -26,6 +33,10 @@ module Applitools
26
33
  def_delegators 'config', *Applitools::Selenium::Configuration.methods_to_delegate
27
34
  def_delegators 'config', *Applitools::EyesBaseConfiguration.methods_to_delegate
28
35
 
36
+ alias runner visual_grid_manager
37
+ attr_accessor :universal_eyes, :universal_driver
38
+ attr_accessor :debug_screenshots, :save_failed_tests, :scale_ratio, :disabled, :stitching_overlap, :compare_with_parent_branch
39
+
29
40
  def initialize(visual_grid_manager, server_url = nil)
30
41
  ensure_config
31
42
  @server_connector = Applitools::Connectivity::ServerConnector.new(server_url)
@@ -43,6 +54,7 @@ module Applitools
43
54
 
44
55
  def ensure_config
45
56
  self.config = Applitools::Selenium::Configuration.new
57
+ self.send_dom = true
46
58
  end
47
59
 
48
60
  def full_agent_id
@@ -56,51 +68,60 @@ module Applitools
56
68
  end
57
69
 
58
70
  def open(*args)
59
- self.test_uuid = SecureRandom.uuid
71
+ # self.test_uuid = SecureRandom.uuid
60
72
  options = Applitools::Utils.extract_options!(args)
61
- Applitools::ArgumentGuard.hash(options, 'options', [:driver])
62
-
63
- config.app_name = options[:app_name] if options[:app_name]
64
- config.test_name = options[:test_name] if options[:test_name]
65
- config.agent_run_id = "#{config.test_name}--#{SecureRandom.hex(10)}"
66
-
67
- if config.viewport_size.nil? || config.viewport_size && config.viewport_size.empty?
68
- config.viewport_size = Applitools::RectangleSize.from_any_argument(options[:viewport_size]) if options[:viewport_size]
69
- end
70
-
71
- self.driver = Applitools::Selenium::SeleniumEyes.eyes_driver(options.delete(:driver), self)
72
- self.current_url = driver.current_url
73
-
74
- if viewport_size
75
- set_viewport_size(viewport_size)
76
- else
77
- self.viewport_size = get_viewport_size
78
- end
79
-
80
- visual_grid_manager.open(self)
81
- visual_grid_manager.add_batch(batch.id) do
82
- server_connector.close_batch(batch.id)
83
- end
84
-
85
- logger.info('Getting all browsers info...')
86
- browsers_info_list = config.browsers_info
87
- logger.info('Creating test descriptors for each browser info...')
88
- browsers_info_list.each(viewport_size) do |bi|
89
- test = Applitools::Selenium::RunningTest.new(eyes_connector, bi, driver).tap do |t|
90
- t.on_results_received do |results|
91
- visual_grid_manager.aggregate_result(results)
92
- end
93
- t.test_uuid = test_uuid
94
- end
95
- test_list.push test
96
- end
97
- self.opened = true
98
- driver
73
+ universal_open(options)
74
+ # Applitools::ArgumentGuard.hash(options, 'options', [:driver])
75
+ #
76
+ # config.app_name = options[:app_name] if options[:app_name]
77
+ # config.test_name = options[:test_name] if options[:test_name]
78
+ # config.agent_run_id = "#{config.test_name}--#{SecureRandom.hex(10)}"
79
+ #
80
+ # if config.viewport_size.nil? || config.viewport_size && config.viewport_size.empty?
81
+ # config.viewport_size = Applitools::RectangleSize.from_any_argument(options[:viewport_size]) if options[:viewport_size]
82
+ # end
83
+ #
84
+ # self.driver = Applitools::Selenium::SeleniumEyes.eyes_driver(options.delete(:driver), self)
85
+ # self.current_url = driver.current_url
86
+ #
87
+ # if viewport_size
88
+ # set_viewport_size(viewport_size)
89
+ # else
90
+ # self.viewport_size = get_viewport_size
91
+ # end
92
+ #
93
+ # visual_grid_manager.open(self)
94
+ # visual_grid_manager.add_batch(batch.id) do
95
+ # server_connector.close_batch(batch.id)
96
+ # end
97
+ #
98
+ # logger.info('Getting all browsers info...')
99
+ # browsers_info_list = config.browsers_info
100
+ # logger.info('Creating test descriptors for each browser info...')
101
+ # browsers_info_list.each(viewport_size) do |bi|
102
+ # test = Applitools::Selenium::RunningTest.new(eyes_connector, bi, driver).tap do |t|
103
+ # t.on_results_received do |results|
104
+ # visual_grid_manager.aggregate_result(results)
105
+ # end
106
+ # t.test_uuid = test_uuid
107
+ # end
108
+ # test_list.push test
109
+ # end
110
+ # self.opened = true
111
+ # driver
99
112
  end
100
113
 
101
114
  def get_viewport_size(web_driver = driver)
102
115
  Applitools::ArgumentGuard.not_nil 'web_driver', web_driver
103
- self.utils.extract_viewport_size(driver)
116
+ # self.utils.extract_viewport_size(driver)
117
+ driver_config_json = universal_driver_config(web_driver)
118
+
119
+ Applitools::EyesLogger.debug 'extract_viewport_size()'
120
+ viewport_size = runner.universal_client.core_get_viewport_size(driver_config_json)
121
+ result = Applitools::RectangleSize.new viewport_size[:width], viewport_size[:height]
122
+
123
+ Applitools::EyesLogger.debug "Viewport size is #{result}."
124
+ result
104
125
  end
105
126
 
106
127
  def eyes_connector
@@ -127,6 +148,8 @@ module Applitools
127
148
  render_task = nil
128
149
  target.default_full_page_for_vg
129
150
 
151
+ return universal_check(tag, target)
152
+
130
153
  target_to_check = target.finalize
131
154
  begin
132
155
  check_in_frame(target_frames: target_to_check.frames) do
@@ -296,21 +319,33 @@ module Applitools
296
319
  end
297
320
 
298
321
  def close(throw_exception = true)
299
- return false if test_list.empty?
300
- close_async
301
-
302
- until (states = test_list.map(&:state_name).uniq).count == 1 && states.first == :completed
303
- sleep 0.5
304
- end
305
- self.opened = false
306
-
307
- test_list.select { |t| t.pending_exceptions && !t.pending_exceptions.empty? }.each do |t|
308
- t.pending_exceptions.each do |e|
309
- raise e
310
- end
311
- end
312
-
313
- all_results = test_list.map(&:test_result).compact
322
+ logger.info "close(#{throw_exception})"
323
+ logger.info 'Ending server session...'
324
+
325
+ universal_results = universal_eyes.close # Array even for one test
326
+ raise Applitools::EyesError.new("Request failed: #{universal_results[:message]}") if server_error?(universal_results)
327
+ key_transformed_results = Applitools::Utils.deep_stringify_keys(universal_results)
328
+ results = key_transformed_results.map {|result| Applitools::TestResults.new(result) }
329
+ # results = results.first if results.size == 1
330
+ # session_results_url = results.url
331
+ all_results = results.compact
332
+
333
+
334
+ # return false if test_list.empty?
335
+ # close_async
336
+ #
337
+ # until (states = test_list.map(&:state_name).uniq).count == 1 && states.first == :completed
338
+ # sleep 0.5
339
+ # end
340
+ # self.opened = false
341
+ #
342
+ # test_list.select { |t| t.pending_exceptions && !t.pending_exceptions.empty? }.each do |t|
343
+ # t.pending_exceptions.each do |e|
344
+ # raise e
345
+ # end
346
+ # end
347
+ #
348
+ # all_results = test_list.map(&:test_result).compact
314
349
  failed_results = all_results.select { |r| !r.as_expected? }
315
350
 
316
351
  if throw_exception
@@ -321,16 +356,18 @@ module Applitools
321
356
  end
322
357
  end
323
358
 
324
- failed_results.empty? ? all_results.first : failed_results
359
+ failed_results.empty? ? all_results.first : failed_results.first
325
360
  end
326
361
 
327
362
  def abort_async
328
363
  test_list.each(&:abort)
364
+ universal_sdk_abort
329
365
  end
330
366
 
331
367
  def abort_if_not_closed
332
368
  self.opened = false
333
369
  test_list.each(&:abort)
370
+ universal_sdk_abort
334
371
  end
335
372
 
336
373
  alias abort abort_if_not_closed
@@ -347,6 +384,8 @@ module Applitools
347
384
 
348
385
  # rubocop:disable Style/AccessorMethodName
349
386
  def set_viewport_size(value)
387
+ # require('pry')
388
+ # binding.pry
350
389
  self.utils.set_viewport_size driver, value
351
390
  rescue => e
352
391
  logger.error e.class.to_s
@@ -398,6 +437,14 @@ module Applitools
398
437
 
399
438
  def add_text_trigger(_control, _text); end
400
439
 
440
+ def disabled=(value)
441
+ @disabled = Applitools::Utils.boolean_value value
442
+ end
443
+
444
+ def disabled?
445
+ @disabled
446
+ end
447
+
401
448
  private :new_test_error_message, :diffs_found_error_message, :test_failed_error_message
402
449
 
403
450
  private
@@ -61,6 +61,10 @@ module Applitools
61
61
  super
62
62
  end
63
63
 
64
+ def universal_eyes_manager_config
65
+ Applitools::UniversalEyesManagerConfig.vg(@thread_pool.concurrency)
66
+ end
67
+
64
68
  private
65
69
 
66
70
  def all_running_tests
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Applitools
4
- VERSION = '3.18.4'.freeze
4
+ VERSION = '4.0.3'.freeze
5
+ UNIVERSAL_VERSION = '2.5.7'.freeze
5
6
  end
data/lib/eyes_selenium.rb CHANGED
@@ -31,5 +31,22 @@ if defined? Selenium::WebDriver::Driver
31
31
  is_mobile_device = capabilities['platformName'] ? true : false
32
32
  Applitools::Selenium::Driver.new(eyes, driver: self, is_mobile_device: is_mobile_device)
33
33
  end
34
+
35
+ def universal_driver_config
36
+ hidden_server_url = bridge.http.send(:server_url).to_s
37
+ if respond_to?(:session_id)
38
+ {
39
+ serverUrl: hidden_server_url,
40
+ sessionId: session_id,
41
+ capabilities: capabilities.as_json
42
+ }
43
+ else
44
+ {
45
+ serverUrl: hidden_server_url,
46
+ sessionId: bridge.session_id,
47
+ capabilities: capabilities.as_json
48
+ }
49
+ end
50
+ end
34
51
  end
35
52
  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.18.4
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Applitools Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-31 00:00:00.000000000 Z
11
+ date: 2022-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eyes_core
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.18.4
19
+ version: 4.0.3
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.18.4
26
+ version: 4.0.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: selenium-webdriver
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '3'
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: '0'
40
+ version: '3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: css_parser
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: nokogiri
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 1.10.10
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 1.10.10
97
97
  description: Provides SDK for writing Applitools Selenium-based tests
98
98
  email:
99
99
  - team@applitools.com
@@ -151,6 +151,8 @@ files:
151
151
  - lib/applitools/selenium/test_list.rb
152
152
  - lib/applitools/selenium/viewport_screenshot.rb
153
153
  - lib/applitools/selenium/viewport_size.rb
154
+ - lib/applitools/selenium/visual_grid/android_device_info.rb
155
+ - lib/applitools/selenium/visual_grid/android_device_name.rb
154
156
  - lib/applitools/selenium/visual_grid/chrome_emulation_info.rb
155
157
  - lib/applitools/selenium/visual_grid/desktop_browser_info.rb
156
158
  - lib/applitools/selenium/visual_grid/dom_snapshot_script.rb