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.
Instance Method Summary collapse
- #app_environment ⇒ Object
- #base_agent_id ⇒ Object
- #capture_screenshot ⇒ Object
- #check(name, target, check_task_uuid) ⇒ Object
- #close(throw_exception = true, be_silent = false) ⇒ Object
- #default_match_settings ⇒ 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.
- #match_level_keys ⇒ Object
- #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
- #title ⇒ Object
- #update_default_settings(match_data) ⇒ Object
- #viewport_size ⇒ Object
Constructor Details
#initialize(*args) ⇒ EyesConnector
Returns a new instance of EyesConnector.
16 17 18 19 20 21 22 23 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 16 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.
6 7 8 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 6 def browser_info @browser_info end |
#current_uuid ⇒ Object
Returns the value of attribute current_uuid.
6 7 8 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 6 def current_uuid @current_uuid end |
#device_name ⇒ Object
Returns the value of attribute device_name.
6 7 8 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 6 def device_name @device_name end |
#dont_get_title ⇒ Object
Returns the value of attribute dont_get_title.
6 7 8 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 6 def dont_get_title @dont_get_title end |
#driver ⇒ Object
Returns the value of attribute driver.
6 7 8 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 6 def driver @driver end |
#driver_lock ⇒ Object
Returns the value of attribute driver_lock.
6 7 8 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 6 def driver_lock @driver_lock end |
#dummy_region_provider ⇒ Object
Returns the value of attribute dummy_region_provider.
6 7 8 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 6 def dummy_region_provider @dummy_region_provider end |
#render_statuses ⇒ Object
Returns the value of attribute render_statuses.
6 7 8 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 6 def render_statuses @render_statuses end |
#test_result ⇒ Object
Returns the value of attribute test_result.
6 7 8 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 6 def test_result @test_result end |
Instance Method Details
#app_environment ⇒ Object
122 123 124 125 126 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 122 def app_environment super.tap do |env| env.device_info = device_name end end |
#base_agent_id ⇒ Object
62 63 64 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 62 def base_agent_id "eyes.selenium.visualgrid.ruby/#{Applitools::VERSION}" end |
#capture_screenshot ⇒ Object
71 72 73 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 71 def capture_screenshot nil end |
#check(name, target, check_task_uuid) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 40 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 update_default_settings(match_data) begin match_data.read_target(target_to_check, driver, selector_regions) 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
66 67 68 69 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 66 def close(throw_exception = true, be_silent = false) self.current_uuid = nil self.test_result = super end |
#default_match_settings ⇒ Object
111 112 113 114 115 116 117 118 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 111 def default_match_settings { match_level: match_level, exact: exact, scale: server_scale, remainder: server_remainder } end |
#dom_url ⇒ Object
89 90 91 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 89 def dom_url render_status['domLocation'] end |
#ensure_config ⇒ Object
25 26 27 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 25 def ensure_config self.config = Applitools::Selenium::Configuration.new end |
#get_app_output_with_screenshot(region_provider, last_screenshot) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 142 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
107 108 109 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 107 def inferred_environment "useragent: #{render_status['userAgent']}" end |
#match_level_keys ⇒ Object
97 98 99 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 97 def match_level_keys %w(match_level exact scale remainder).map(&:to_sym) end |
#open(driver, browser_info) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# 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. open_base # ensure_running_session end |
#render_status ⇒ Object
79 80 81 82 83 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 79 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
75 76 77 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 75 def render_status_for_task(uuid, status) render_statuses[uuid] = status end |
#screenshot_url ⇒ Object
85 86 87 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 85 def screenshot_url render_status['imageLocation'] end |
#selector_regions ⇒ Object
93 94 95 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 93 def selector_regions render_status['selectorRegions'] end |
#set_viewport_size(*_args) ⇒ Object
120 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 120 def (*_args); end |
#title ⇒ Object
134 135 136 137 138 139 140 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 134 def title return driver.title unless dont_get_title rescue StandardError => e logger.warn "failed (#{e.})" self.dont_get_title = false '' end |
#update_default_settings(match_data) ⇒ Object
101 102 103 104 105 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 101 def update_default_settings(match_data) match_level_keys.each do |k| match_data.send("#{k}=", default_match_settings[k]) end end |
#viewport_size ⇒ Object
128 129 130 131 132 |
# File 'lib/applitools/selenium/visual_grid/eyes_connector.rb', line 128 def status = render_statuses[render_statuses.keys.first] size = status['deviceSize'] Applitools::RectangleSize.new(size['width'], size['height']) end |