Class: Applitools::Selenium::VisualGridEyes
- Inherits:
-
Object
- Object
- Applitools::Selenium::VisualGridEyes
- Extended by:
- Forwardable
- Includes:
- Concerns::SeleniumEyes, UniversalEyesChecks, UniversalEyesOpen, UniversalNewApi
- Defined in:
- lib/applitools/selenium/visual_grid/visual_grid_eyes.rb
Constant Summary collapse
- USE_DEFAULT_MATCH_TIMEOUT =
-1
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#compare_with_parent_branch ⇒ Object
Returns the value of attribute compare_with_parent_branch.
-
#current_config ⇒ Object
Returns the value of attribute current_config.
-
#current_url ⇒ Object
Returns the value of attribute current_url.
-
#debug_screenshots ⇒ Object
Returns the value of attribute debug_screenshots.
-
#disabled ⇒ Object
Returns the value of attribute disabled.
-
#dont_get_title ⇒ Object
Returns the value of attribute dont_get_title.
-
#driver ⇒ Object
Returns the value of attribute driver.
-
#driver_lock ⇒ Object
Returns the value of attribute driver_lock.
-
#enable_patterns ⇒ Object
Returns the value of attribute enable_patterns.
-
#fetched_cache_map ⇒ Object
Returns the value of attribute fetched_cache_map.
-
#opened ⇒ Object
Returns the value of attribute opened.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
-
#save_failed_tests ⇒ Object
Returns the value of attribute save_failed_tests.
-
#scale_ratio ⇒ Object
Returns the value of attribute scale_ratio.
-
#server_url ⇒ Object
Returns the value of attribute server_url.
-
#stitching_overlap ⇒ Object
Returns the value of attribute stitching_overlap.
-
#test_list ⇒ Object
Returns the value of attribute test_list.
-
#universal_driver ⇒ Object
Returns the value of attribute universal_driver.
-
#universal_eyes ⇒ Object
Returns the value of attribute universal_eyes.
-
#utils ⇒ Object
Returns the value of attribute utils.
-
#visual_grid_manager ⇒ Object
(also: #runner)
Returns the value of attribute visual_grid_manager.
Class Method Summary collapse
Instance Method Summary collapse
- #abort_async ⇒ Object
- #abort_if_not_closed ⇒ Object (also: #abort)
- #add_mouse_trigger(_mouse_action, _element) ⇒ Object
- #add_text_trigger(_control, _text) ⇒ Object
- #check(*args) ⇒ Object
- #close(throw_exception = true) ⇒ Object
- #close_async ⇒ Object
- #collect_selenium_regions(target) ⇒ Object
- #configuration ⇒ Object (also: #get_configuration)
- #configuration=(value) ⇒ Object (also: #set_configuration)
- #configure {|config| ... } ⇒ Object
- #disabled? ⇒ Boolean
- #element_or_region(target_element, target, options_key) ⇒ Object
- #ensure_config ⇒ Object
- #eyes_connector ⇒ Object
- #full_agent_id ⇒ Object
-
#get_all_test_results ⇒ Object
rubocop:disable Style/AccessorMethodName.
- #get_regions_x_paths(target) ⇒ Object
- #get_results(throw_exception = true) ⇒ Object
- #get_viewport_size(web_driver = driver) ⇒ Object
-
#initialize(visual_grid_manager, server_url = nil) ⇒ VisualGridEyes
constructor
A new instance of VisualGridEyes.
- #open(*args) ⇒ Object
- #open? ⇒ Boolean
- #server_connector ⇒ Object
-
#set_viewport_size(value) ⇒ Object
rubocop:disable Style/AccessorMethodName.
- #setup_size_mode(target_element, target, key) ⇒ Object
Methods included from Concerns::SeleniumEyes
#check_frame, #check_in_frame, #check_region, #check_region_in_frame, #check_window, #test
Constructor Details
#initialize(visual_grid_manager, server_url = nil) ⇒ VisualGridEyes
Returns a new instance of VisualGridEyes.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 41 def initialize(visual_grid_manager, server_url = nil) ensure_config @server_connector = Applitools::Connectivity::ServerConnector.new(server_url) @server_connector.obtain_agent_id do full_agent_id end self.server_url = server_url if server_url self.visual_grid_manager = visual_grid_manager self.test_list = Applitools::Selenium::TestList.new self.opened = false self.test_list ||= Applitools::Selenium::TestList.new self.driver_lock = Mutex.new self.utils = Applitools::Utils::EyesSeleniumUtils end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
29 30 31 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 29 def api_key @api_key end |
#compare_with_parent_branch ⇒ Object
Returns the value of attribute compare_with_parent_branch.
39 40 41 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 39 def compare_with_parent_branch @compare_with_parent_branch end |
#current_config ⇒ Object
Returns the value of attribute current_config.
23 24 25 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 23 def current_config @current_config end |
#current_url ⇒ Object
Returns the value of attribute current_url.
23 24 25 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 23 def current_url @current_url end |
#debug_screenshots ⇒ Object
Returns the value of attribute debug_screenshots.
39 40 41 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 39 def debug_screenshots @debug_screenshots end |
#disabled ⇒ Object
Returns the value of attribute disabled.
39 40 41 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 39 def disabled @disabled end |
#dont_get_title ⇒ Object
Returns the value of attribute dont_get_title.
23 24 25 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 23 def dont_get_title @dont_get_title end |
#driver ⇒ Object
Returns the value of attribute driver.
23 24 25 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 23 def driver @driver end |
#driver_lock ⇒ Object
Returns the value of attribute driver_lock.
23 24 25 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 23 def driver_lock @driver_lock end |
#enable_patterns ⇒ Object
Returns the value of attribute enable_patterns.
23 24 25 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 23 def enable_patterns @enable_patterns end |
#fetched_cache_map ⇒ Object
Returns the value of attribute fetched_cache_map.
23 24 25 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 23 def fetched_cache_map @fetched_cache_map end |
#opened ⇒ Object
Returns the value of attribute opened.
29 30 31 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 29 def opened @opened end |
#proxy ⇒ Object
Returns the value of attribute proxy.
29 30 31 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 29 def proxy @proxy end |
#save_failed_tests ⇒ Object
Returns the value of attribute save_failed_tests.
39 40 41 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 39 def save_failed_tests @save_failed_tests end |
#scale_ratio ⇒ Object
Returns the value of attribute scale_ratio.
39 40 41 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 39 def scale_ratio @scale_ratio end |
#server_url ⇒ Object
Returns the value of attribute server_url.
29 30 31 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 29 def server_url @server_url end |
#stitching_overlap ⇒ Object
Returns the value of attribute stitching_overlap.
39 40 41 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 39 def stitching_overlap @stitching_overlap end |
#test_list ⇒ Object
Returns the value of attribute test_list.
27 28 29 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 27 def test_list @test_list end |
#universal_driver ⇒ Object
Returns the value of attribute universal_driver.
38 39 40 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 38 def universal_driver @universal_driver end |
#universal_eyes ⇒ Object
Returns the value of attribute universal_eyes.
38 39 40 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 38 def universal_eyes @universal_eyes end |
#utils ⇒ Object
Returns the value of attribute utils.
23 24 25 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 23 def utils @utils end |
#visual_grid_manager ⇒ Object Also known as: runner
Returns the value of attribute visual_grid_manager.
23 24 25 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 23 def visual_grid_manager @visual_grid_manager end |
Class Method Details
.environment_sdk ⇒ Object
56 57 58 59 60 61 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 56 def self.environment_sdk { name: :eyes_selenium, currentVersion: Applitools::EyesSelenium::VERSION } end |
Instance Method Details
#abort_async ⇒ Object
399 400 401 402 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 399 def abort_async test_list.each(&:abort) universal_sdk_abort end |
#abort_if_not_closed ⇒ Object Also known as: abort
404 405 406 407 408 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 404 def abort_if_not_closed self.opened = false test_list.each(&:abort) universal_sdk_abort end |
#add_mouse_trigger(_mouse_action, _element) ⇒ Object
473 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 473 def add_mouse_trigger(_mouse_action, _element); end |
#add_text_trigger(_control, _text) ⇒ Object
475 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 475 def add_text_trigger(_control, _text); end |
#check(*args) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 144 def check(*args) args.compact! case (first_arg = args.shift) when String tag = first_arg target = args.shift when Applitools::Selenium::Target target = first_arg when Hash target = first_arg[:target] tag = first_arg[:name] || first_arg[:tag] end render_task = nil target.default_full_page_for_vg return universal_check(tag, target) target_to_check = target.finalize begin check_in_frame(target_frames: target_to_check.frames) do sleep wait_before_screenshots Applitools::EyesLogger.info 'Trying to get DOM snapshot...' begin dont_fetch_resources = self.dont_fetch_resources enable_cross_origin_rendering = self.enable_cross_origin_rendering = !self. urls_to_skip = visual_grid_manager.resource_cache.urls_to_skip dom_script = Applitools::Selenium::DomSnapshotScript.new driver script_dom = dom_script.create_dom_snapshot( dont_fetch_resources, urls_to_skip, enable_cross_origin_rendering, ) rescue StandardError => e Applitools::EyesLogger.error e.class.to_s Applitools::EyesLogger.error e. raise ::Applitools::EyesError.new 'Error while getting dom snapshot!' end Applitools::EyesLogger.info 'Done!' mod = Digest::SHA2.hexdigest(script_dom.to_s) region_x_paths = get_regions_x_paths(target_to_check) render_task = RenderTask.new( "Render #{config.short_description} - #{tag}", script_dom, visual_grid_manager, server_connector, region_x_paths, size_mod, region_to_check, target_to_check.[:script_hooks], config.rendering_grid_force_put, self.utils.user_agent(driver), .merge(target_to_check.[:visual_grid_options]), mod ) end if size_mod == 'selector' || size_mod == 'full-selector' target_to_check.convert_coordinates(&Applitools::Selenium::VgMatchWindowData::CONVERT_COORDINATES) end title = begin driver.title rescue StandardError => e logger.warn "failed (#{e.})" '' end test_list.select { |t| t.test_uuid == test_uuid }.each do |t| t.check(tag, target_to_check, render_task, title) end test_list.each(&:becomes_not_rendered) visual_grid_manager.enqueue_render_task render_task rescue StandardError => e test_list.each(&:becomes_tested) Applitools::EyesLogger.error e.class.to_s Applitools::EyesLogger.error e. end end |
#close(throw_exception = true) ⇒ Object
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 331 def close(throw_exception = true) logger.info "close(#{throw_exception})" logger.info 'Ending server session...' raise Applitools::EyesNotOpenException.new 'Eyes not open' unless open? universal_results = universal_eyes.close # Array even for one test self.opened = false all_results = get_results(throw_exception) # universal_results = universal_eyes.eyes_get_results # Array even for one test # # require 'pry' # # binding.pry # raise Applitools::EyesError.new("Request failed: #{universal_results[:message]}") if server_error?(universal_results) # results = universal_results.map {|result| Applitools::TestResults.new(result) } # # results = results.first if results.size == 1 # # session_results_url = results.url # all_results = results.compact # return false if test_list.empty? # close_async # # until (states = test_list.map(&:state_name).uniq).count == 1 && states.first == :completed # sleep 0.5 # end # self.opened = false # # test_list.select { |t| t.pending_exceptions && !t.pending_exceptions.empty? }.each do |t| # t.pending_exceptions.each do |e| # raise e # end # end # # all_results = test_list.map(&:test_result).compact # failed_results = all_results.select { |r| !r.as_expected? } # # if throw_exception # all_results.each do |r| # raise Applitools::NewTestError.new new_test_error_message(r), r if r.new? # raise Applitools::DiffsFoundError.new diffs_found_error_message(r), r if r.unresolved? && !r.new? # raise Applitools::TestFailedError.new test_failed_error_message(r), r if r.failed? # end # end # failed_results.empty? ? all_results.first : failed_results.first all_results.first end |
#close_async ⇒ Object
326 327 328 329 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 326 def close_async # test_list.each(&:close) close(false) end |
#collect_selenium_regions(target) ⇒ Object
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 244 def collect_selenium_regions(target) selenium_regions = {} target_element = target.region_to_check setup_size_mode(target_element, target, :none) target.ignored_regions.each do |r| selenium_regions[element_or_region(r, target, :ignore)] = :ignore end target.floating_regions.each do |r| selenium_regions[element_or_region(r, target, :floating)] = :floating end target.layout_regions.each do |r| selenium_regions[element_or_region(r, target, :layout_regions)] = :layout end target.strict_regions.each do |r| selenium_regions[element_or_region(r, target, :strict_regions)] = :strict end target.content_regions.each do |r| selenium_regions[element_or_region(r, target, :content_regions)] = :content end target.accessibility_regions.each do |r| case (r = element_or_region(r, target, :accessibility_regions)) when Array r.each do |rr| selenium_regions[rr] = :accessibility end else selenium_regions[r] = :accessibility end end selenium_regions[region_to_check] = :target if size_mod == 'selector' || size_mod == 'full-selector' selenium_regions end |
#configuration ⇒ Object Also known as: get_configuration
461 462 463 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 461 def configuration config.deep_dup end |
#configuration=(value) ⇒ Object Also known as: set_configuration
465 466 467 468 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 465 def configuration=(value) Applitools::ArgumentGuard.is_a?(value, :configuration, Applitools::Selenium::Configuration) self.config = value.deep_dup end |
#configure {|config| ... } ⇒ Object
72 73 74 75 76 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 72 def configure return unless block_given? yield(config) nil end |
#disabled? ⇒ Boolean
481 482 483 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 481 def disabled? @disabled end |
#element_or_region(target_element, target, options_key) ⇒ Object
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 310 def element_or_region(target_element, target, ) if target_element.respond_to?(:call) region, padding_proc = target_element.call(driver, true) case region when Array regions_to_replace = region.map { |r| Applitools::Selenium::VGRegion.new(r, padding_proc) } target.replace_region(target_element, regions_to_replace, ) else target.replace_region(target_element, Applitools::Selenium::VGRegion.new(region, padding_proc), ) end region else target_element end end |
#ensure_config ⇒ Object
63 64 65 66 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 63 def ensure_config self.config = Applitools::Selenium::Configuration.new self.send_dom = true end |
#eyes_connector ⇒ Object
136 137 138 139 140 141 142 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 136 def eyes_connector logger.info('Creating VisualGridEyes server connector') ::Applitools::Selenium::EyesConnector.new(server_url, driver_lock: driver_lock).tap do |connector| connector.batch = batch connector.config = config.deep_clone end end |
#full_agent_id ⇒ Object
68 69 70 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 68 def full_agent_id "eyes.selenium.visualgrid.ruby/#{Applitools::VERSION}" end |
#get_all_test_results ⇒ Object
rubocop:disable Style/AccessorMethodName
417 418 419 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 417 def get_all_test_results test_list.map(&:test_result) end |
#get_regions_x_paths(target) ⇒ Object
230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 230 def get_regions_x_paths(target) result = [] collect_selenium_regions(target).each do |el, v| next unless [::Selenium::WebDriver::Element, Applitools::Selenium::Element].include?(el.class) xpath = driver.execute_script(Applitools::Selenium::Scripts::GET_ELEMENT_XPATH_JS, el) web_element_region = Applitools::Selenium::WebElementRegion.new(xpath, v) self.region_to_check = web_element_region.dup if v == :target && (size_mod == 'selector' || size_mod == 'full-selector') result << web_element_region target.regions[el] = result.size - 1 end result end |
#get_results(throw_exception = true) ⇒ Object
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 378 def get_results(throw_exception = true) logger.info "get_results(#{throw_exception})" logger.info 'Getting results...' universal_results = universal_eyes.eyes_get_results # Array even for one test # require 'pry' # binding.pry raise Applitools::EyesError.new("Request failed: #{universal_results[:message]}") if server_error?(universal_results) results = universal_results.map {|result| Applitools::TestResults.new(result) } all_results = results.compact if throw_exception all_results.each do |r| raise Applitools::NewTestError.new (r), r if r.new? raise Applitools::DiffsFoundError.new (r), r if r.unresolved? && !r.new? raise Applitools::TestFailedError.new (r), r if r.failed? end end all_results end |
#get_viewport_size(web_driver = driver) ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 123 def (web_driver = driver) Applitools::ArgumentGuard.not_nil 'web_driver', web_driver # self.utils.extract_viewport_size(driver) driver_config_json = universal_driver_config(web_driver) Applitools::EyesLogger.debug 'extract_viewport_size()' = runner.universal_client.(driver_config_json) result = Applitools::RectangleSize.new [:width], [:height] Applitools::EyesLogger.debug "Viewport size is #{result}." result end |
#open(*args) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 78 def open(*args) # visual_grid_manager.add_batch(batch.id) { visual_grid_manager.close_batch(batch.id) } # self.test_uuid = SecureRandom.uuid = Applitools::Utils.(args) universal_open() # Applitools::ArgumentGuard.hash(options, 'options', [:driver]) # # config.app_name = options[:app_name] if options[:app_name] # config.test_name = options[:test_name] if options[:test_name] # config.agent_run_id = "#{config.test_name}--#{SecureRandom.hex(10)}" # # if config.viewport_size.nil? || config.viewport_size && config.viewport_size.empty? # config.viewport_size = Applitools::RectangleSize.from_any_argument(options[:viewport_size]) if options[:viewport_size] # end # # self.driver = Applitools::Selenium::SeleniumEyes.eyes_driver(options.delete(:driver), self) # self.current_url = driver.current_url # # if viewport_size # set_viewport_size(viewport_size) # else # self.viewport_size = get_viewport_size # end # # visual_grid_manager.open(self) # visual_grid_manager.add_batch(batch.id) do # server_connector.close_batch(batch.id) # end # # logger.info('Getting all browsers info...') # browsers_info_list = config.browsers_info # logger.info('Creating test descriptors for each browser info...') # browsers_info_list.each(viewport_size) do |bi| # test = Applitools::Selenium::RunningTest.new(eyes_connector, bi, driver).tap do |t| # t.on_results_received do |results| # visual_grid_manager.aggregate_result(results) # end # t.test_uuid = test_uuid # end # test_list.push test # end # self.opened = true # driver end |
#open? ⇒ Boolean
412 413 414 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 412 def open? opened end |
#server_connector ⇒ Object
454 455 456 457 458 459 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 454 def server_connector @server_connector.server_url = config.server_url @server_connector.api_key = config.api_key @server_connector.proxy = config.proxy if config.proxy @server_connector end |
#set_viewport_size(value) ⇒ Object
rubocop:disable Style/AccessorMethodName
423 424 425 426 427 428 429 430 431 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 423 def (value) # require('pry') # binding.pry self.utils. driver, value rescue => e logger.error e.class.to_s logger.error e. raise Applitools::TestFailedError.new "#{e.class} - #{e.}" end |
#setup_size_mode(target_element, target, key) ⇒ Object
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
# File 'lib/applitools/selenium/visual_grid/visual_grid_eyes.rb', line 278 def setup_size_mode(target_element, target, key) self.size_mod = 'full-page' element_or_region = element_or_region(target_element, target, key) self.size_mod = case element_or_region when ::Selenium::WebDriver::Element, Applitools::Selenium::Element if target.[:stitch_content] 'full-selector' else 'selector' end when Applitools::Region if element_or_region == Applitools::Region::EMPTY if target.[:stitch_content] 'full-page' else element_or_region = Applitools::Region.from_location_size( Applitools::Location::TOP_LEFT, ) 'region' end else 'region' end else 'full-page' end self.region_to_check = element_or_region end |