Class: Wayfarer::HTTPAdapters::SeleniumAdapter Private

Inherits:
Object
  • Object
show all
Defined in:
lib/wayfarer/http_adapters/selenium_adapter.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

An adapter for Selenium WebDrivers

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = Wayfarer.config) ⇒ SeleniumAdapter

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SeleniumAdapter.


16
17
18
# File 'lib/wayfarer/http_adapters/selenium_adapter.rb', line 16

def initialize(config = Wayfarer.config)
  @config = config
end

Instance Attribute Details

#driverObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The WebDriver.


14
15
16
# File 'lib/wayfarer/http_adapters/selenium_adapter.rb', line 14

def driver
  @driver
end

Instance Method Details

#browserObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

A Capybara driver that wraps the #driver.

See Also:


52
53
54
# File 'lib/wayfarer/http_adapters/selenium_adapter.rb', line 52

def browser
  @browser ||= instantiate_capybara_driver
end

#fetch(uri) ⇒ Page

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Fetches a page.

Returns:


22
23
24
25
26
27
28
29
30
31
# File 'lib/wayfarer/http_adapters/selenium_adapter.rb', line 22

def fetch(uri)
  driver.navigate.to(uri)

  Page.new(
    uri: @driver.current_url,
    status_code: @driver.response_code,
    body: @driver.page_source,
    headers: @driver.response_headers
  )
end

#freeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Quits the browser.


40
41
42
43
# File 'lib/wayfarer/http_adapters/selenium_adapter.rb', line 40

def free
  @driver&.quit
  @driver = nil
end

#reload!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Closes the driver.


34
35
36
37
# File 'lib/wayfarer/http_adapters/selenium_adapter.rb', line 34

def reload!
  @driver&.close
  @driver = nil
end