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
-
#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.
-
#update_default_settings(match_data) ⇒ Object
def match_level_keys %w(match_level exact scale remainder ).map(&:to_sym) end.
- #viewport_size ⇒ Object
Constructor Details
#initialize(*args) ⇒ EyesConnector
Returns a new instance of EyesConnector.
17 18 19 20 21 22 23 24 |
# 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] 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
129 130 131 132 133 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 129 def app_environment super.tap do |env| env.device_info = device_name end end |
#base_agent_id ⇒ Object
66 67 68 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 66 def base_agent_id "eyes.selenium.visualgrid.ruby/#{Applitools::VERSION}" end |
#capture_screenshot ⇒ Object
75 76 77 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 75 def capture_screenshot nil end |
#check(name, target, check_task_uuid) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 41 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 match_data.tag = name match_data.render_id = render_status['renderId'] update_default_settings(match_data) 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 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
70 71 72 73 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 70 def close(throw_exception = true, be_silent = false) self.current_uuid = nil self.test_result = super end |
#dom_url ⇒ Object
94 95 96 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 94 def dom_url render_status['domLocation'] end |
#ensure_config ⇒ Object
26 27 28 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 26 def ensure_config self.config = Applitools::Selenium::Configuration.new end |
#get_app_output_with_screenshot(region_provider, _last_screenshot) ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 149 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? end, nil, true ) end |
#inferred_environment ⇒ Object
112 113 114 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 112 def inferred_environment "useragent: #{render_status['userAgent']}" end |
#open(driver, browser_info) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 30 def open(driver, browser_info) self.driver = driver self.browser_info = browser_info self.device_name = browser_info && browser_info.emulation_info && browser_info.emulation_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
83 84 85 86 87 88 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 83 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
79 80 81 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 79 def render_status_for_task(uuid, status) render_statuses[uuid] = status end |
#screenshot_url ⇒ Object
90 91 92 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 90 def screenshot_url render_status['imageLocation'] end |
#selector_regions ⇒ Object
98 99 100 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 98 def selector_regions render_status['selectorRegions'] end |
#set_viewport_size(*_args) ⇒ Object
rubocop:disable Style/AccessorMethodName
126 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 126 def (*_args); end |
#update_default_settings(match_data) ⇒ Object
def match_level_keys
%w(match_level exact scale remainder ).map(&:to_sym)
end
106 107 108 109 110 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 106 def update_default_settings(match_data) config.match_level_keys.each do |k| match_data.send("#{k}=", default_match_settings[k]) end end |
#viewport_size ⇒ Object
135 136 137 138 139 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 135 def status = render_statuses[render_statuses.keys.first] size = status['deviceSize'] Applitools::RectangleSize.new(size['width'], size['height']) end |