Class: Vessel::Driver::Ferrum::Driver

Inherits:
Vessel::Driver show all
Defined in:
lib/vessel/driver/ferrum/driver.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  timeout: 60,
  js_errors: false,
  process_timeout: 30,
  pending_connection_errors: false,
  browser_options: { "ignore-certificate-errors" => nil }
}.freeze

Instance Attribute Summary

Attributes inherited from Vessel::Driver

#browser, #proxy, #settings

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Vessel::Driver

driver_name, #go_to, indirect_network_errors, #initialize, #restart

Constructor Details

This class inherits a constructor from Vessel::Driver

Class Method Details

.direct_network_errorsObject



18
19
20
# File 'lib/vessel/driver/ferrum/driver.rb', line 18

def self.direct_network_errors
  @direct_network_errors ||= (super + [::Ferrum::TimeoutError, ::Ferrum::StatusError]).freeze
end

Instance Method Details

#create_page(proxy: nil) ⇒ Object



34
35
36
37
38
39
# File 'lib/vessel/driver/ferrum/driver.rb', line 34

def create_page(proxy: nil)
  options = {}
  options.merge!(proxy: proxy) if proxy
  page = browser.create_page(**options)
  Page.new(page, context: browser.contexts[page.context_id])
end

#startObject



24
25
26
27
# File 'lib/vessel/driver/ferrum/driver.rb', line 24

def start
  driver_options = settings.fetch(:driver_options, {})
  @browser = ::Ferrum::Browser.new(**DEFAULT_OPTIONS, **driver_options)
end

#stopObject



29
30
31
32
# File 'lib/vessel/driver/ferrum/driver.rb', line 29

def stop
  browser&.quit
  @browser = nil
end