Class: Wayfarer::HTTPAdapters::SeleniumAdapter Private
- Inherits:
-
Object
- Object
- Wayfarer::HTTPAdapters::SeleniumAdapter
- 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
-
#driver ⇒ Object
readonly
private
The WebDriver.
Instance Method Summary collapse
-
#browser ⇒ Object
private
A Capybara driver that wraps the #driver.
-
#fetch(uri) ⇒ Page
private
Fetches a page.
-
#free ⇒ Object
private
Quits the browser.
-
#initialize(config = Wayfarer.config) ⇒ SeleniumAdapter
constructor
private
A new instance of SeleniumAdapter.
-
#reload! ⇒ Object
private
Closes the driver.
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
#driver ⇒ Object (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
#browser ⇒ 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.
A Capybara driver that wraps the #driver.
52 53 54 |
# File 'lib/wayfarer/http_adapters/selenium_adapter.rb', line 52 def browser @browser ||= 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.
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 |
#free ⇒ 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.
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 |