Class: Applitools::Selenium::EyesConnector
- Inherits:
- 
      EyesBase
      
        - Object
- EyesBase
- Applitools::Selenium::EyesConnector
 
- Defined in:
- lib/applitools/selenium/visual_grid/eyes_connector.rb
Defined Under Namespace
Classes: RegionProvider
Constant Summary collapse
- USE_DEFAULT_MATCH_TIMEOUT =
- -1 
Instance Attribute Summary collapse
- 
  
    
      #browser_info  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute browser_info. 
- 
  
    
      #current_uuid  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute current_uuid. 
- 
  
    
      #device_name  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute device_name. 
- 
  
    
      #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. 
- 
  
    
      #dummy_region_provider  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute dummy_region_provider. 
- 
  
    
      #render_statuses  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute render_statuses. 
- 
  
    
      #test_result  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute test_result. 
- 
  
    
      #title  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute title. 
Instance Method Summary collapse
- 
  
    
      #app_environment  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    rubocop:enable Style/AccessorMethodName. 
- #base_agent_id ⇒ Object
- #capture_screenshot ⇒ Object
- #check(name, target, check_task_uuid) ⇒ Object
- #close(throw_exception = true, be_silent = false) ⇒ Object
- #dom_url ⇒ Object
- #ensure_config ⇒ Object
- #get_app_output_with_screenshot(region_provider, _last_screenshot) ⇒ Object
- 
  
    
      #inferred_environment  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    def match_level_keys %w(match_level exact scale remainder ).map(&:to_sym) end. 
- 
  
    
      #initialize(*args)  ⇒ EyesConnector 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of EyesConnector. 
- #open(driver, browser_info) ⇒ Object
- #render_status ⇒ Object
- #render_status_for_task(uuid, status) ⇒ Object
- #screenshot_url ⇒ Object
- #selector_regions ⇒ Object
- 
  
    
      #set_viewport_size(*_args)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    rubocop:disable Style/AccessorMethodName. 
- #start_session ⇒ Object
- #viewport_size ⇒ Object
- #visual_viewport ⇒ Object
Constructor Details
#initialize(*args) ⇒ EyesConnector
Returns a new instance of EyesConnector.
| 17 18 19 20 21 22 23 24 25 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 17 def initialize(*args) = Applitools::Utils.(args) super self.render_statuses = {} self.dummy_region_provider = RegionProvider.new self.dont_get_title = false self.driver_lock = [:driver_lock] self.should_match_window_run_once_on_timeout = true end | 
Instance Attribute Details
#browser_info ⇒ Object
Returns the value of attribute browser_info.
| 7 8 9 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 7 def browser_info @browser_info end | 
#current_uuid ⇒ Object
Returns the value of attribute current_uuid.
| 7 8 9 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 7 def current_uuid @current_uuid end | 
#device_name ⇒ Object
Returns the value of attribute device_name.
| 7 8 9 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 7 def device_name @device_name end | 
#dont_get_title ⇒ Object
Returns the value of attribute dont_get_title.
| 7 8 9 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 7 def dont_get_title @dont_get_title end | 
#driver ⇒ Object
Returns the value of attribute driver.
| 7 8 9 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 7 def driver @driver end | 
#driver_lock ⇒ Object
Returns the value of attribute driver_lock.
| 7 8 9 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 7 def driver_lock @driver_lock end | 
#dummy_region_provider ⇒ Object
Returns the value of attribute dummy_region_provider.
| 7 8 9 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 7 def dummy_region_provider @dummy_region_provider end | 
#render_statuses ⇒ Object
Returns the value of attribute render_statuses.
| 7 8 9 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 7 def render_statuses @render_statuses end | 
#test_result ⇒ Object
Returns the value of attribute test_result.
| 7 8 9 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 7 def test_result @test_result end | 
#title ⇒ Object
Returns the value of attribute title.
| 7 8 9 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 7 def title @title end | 
Instance Method Details
#app_environment ⇒ Object
rubocop:enable Style/AccessorMethodName
| 134 135 136 137 138 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 134 def app_environment super.tap do |env| env.device_info = device_name end end | 
#base_agent_id ⇒ Object
| 73 74 75 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 73 def base_agent_id "eyes.selenium.visualgrid.ruby/#{Applitools::VERSION}" end | 
#capture_screenshot ⇒ Object
| 82 83 84 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 82 def capture_screenshot nil end | 
#check(name, target, check_task_uuid) ⇒ Object
| 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 42 def check(name, target, check_task_uuid) self.current_uuid = check_task_uuid target_to_check = target.finalize timeout = target_to_check.[:timeout] || USE_DEFAULT_MATCH_TIMEOUT match_data = Applitools::Selenium::VgMatchWindowData.new(default_match_settings) match_data.tag = name match_data.render_id = render_status['renderId'] begin driver_lock.synchronize do match_data.read_target(target_to_check, driver, selector_regions) end rescue Applitools::Selenium::VgMatchWindowData::RegionCoordinatesError => e logger.error "Error retrieving coordinates for region #{e.region}" logger.error e. end match_data.variation_group_id = match_data.target.[:variation_group_id] if match_data.target.[:variation_group_id] check_result = check_window_base( dummy_region_provider, timeout, match_data ) self.current_uuid = nil check_result end | 
#close(throw_exception = true, be_silent = false) ⇒ Object
| 77 78 79 80 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 77 def close(throw_exception = true, be_silent = false) self.current_uuid = nil self.test_result = super end | 
#dom_url ⇒ Object
| 101 102 103 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 101 def dom_url render_status['domLocation'] end | 
#ensure_config ⇒ Object
| 27 28 29 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 27 def ensure_config self.config = Applitools::Selenium::Configuration.new end | 
#get_app_output_with_screenshot(region_provider, _last_screenshot) ⇒ Object
| 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 154 def get_app_output_with_screenshot(region_provider, _last_screenshot) region = region_provider.region a_title = title Applitools::AppOutputWithScreenshot.new( Applitools::AppOutput.new(a_title, '').tap do |o| o.location = region.location unless region.empty? o.dom_url = dom_url o.screenshot_url = screenshot_url if respond_to?(:screenshot_url) && !screenshot_url.nil? o. = unless .nil? end, nil, true ) end | 
#inferred_environment ⇒ Object
def match_level_keys
%w(match_level exact scale remainder ).map(&:to_sym)
end
| 117 118 119 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 117 def inferred_environment "useragent: #{render_status['userAgent']}" end | 
#open(driver, browser_info) ⇒ Object
| 31 32 33 34 35 36 37 38 39 40 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 31 def open(driver, browser_info) self.driver = driver self.browser_info = browser_info self.device_name = browser_info.device_name logger.info "opening EyesConnector for #{config.short_description} with viewport size: #{browser_info}" config. = browser_info. title open_base # ensure_running_session end | 
#render_status ⇒ Object
| 90 91 92 93 94 95 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 90 def render_status status = render_statuses[current_uuid] raise Applitools::EyesError, 'Got empty render status!' if status.nil? || !status.is_a?(Hash) || status.keys.empty? status end | 
#render_status_for_task(uuid, status) ⇒ Object
| 86 87 88 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 86 def render_status_for_task(uuid, status) render_statuses[uuid] = status end | 
#screenshot_url ⇒ Object
| 97 98 99 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 97 def screenshot_url render_status['imageLocation'] end | 
#selector_regions ⇒ Object
| 105 106 107 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 105 def selector_regions render_status['selectorRegions'] end | 
#set_viewport_size(*_args) ⇒ Object
rubocop:disable Style/AccessorMethodName
| 131 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 131 def (*_args); end | 
#start_session ⇒ Object
| 68 69 70 71 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 68 def start_session super self.should_match_window_run_once_on_timeout = true end | 
#viewport_size ⇒ Object
| 140 141 142 143 144 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 140 def status = render_statuses[render_statuses.keys.first] size = status['deviceSize'] Applitools::RectangleSize.new(size['width'], size['height']) end | 
#visual_viewport ⇒ Object
| 109 110 111 | # File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 109 def render_status['visualViewport'] end |