Class: Async::WebDriver::Bridge::Firefox
- Defined in:
- lib/async/webdriver/bridge/firefox.rb
Overview
A bridge to the Firefox browser using geckodriver.
“‘ ruby begin bridge = Async::WebDriver::Bridge::Firefox.start client = Async::WebDriver::Client.open(bridge.endpoint) ensure bridge&.close end
Instance Attribute Summary
Attributes inherited from Generic
#The status of the driver after a connection has been established., #status
Instance Method Summary collapse
- #arguments ⇒ Object
-
#close ⇒ Object
Close the driver.
-
#default_capabilities(headless: true) ⇒ Object
The default capabilities for the Firefox browser which need to be provided when requesting a new session.
-
#initialize(path: "geckodriver") ⇒ Firefox
constructor
Create a new bridge to Firefox.
-
#start ⇒ Object
Start the driver.
- #version ⇒ Object
Methods inherited from Generic
#endpoint, #port, start, #supported?
Constructor Details
#initialize(path: "geckodriver") ⇒ Firefox
Create a new bridge to Firefox.
24 25 26 27 28 29 |
# File 'lib/async/webdriver/bridge/firefox.rb', line 24 def initialize(path: "geckodriver") super() @path = path @process = nil end |
Instance Method Details
#arguments ⇒ Object
41 42 43 44 45 |
# File 'lib/async/webdriver/bridge/firefox.rb', line 41 def arguments [ "--port", self.port.to_s, ].compact end |
#close ⇒ Object
Close the driver.
55 56 57 58 59 60 61 62 |
# File 'lib/async/webdriver/bridge/firefox.rb', line 55 def close super if @process @process.close @process = nil end end |
#default_capabilities(headless: true) ⇒ Object
The default capabilities for the Firefox browser which need to be provided when requesting a new session.
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/async/webdriver/bridge/firefox.rb', line 67 def default_capabilities(headless: true) { alwaysMatch: { browserName: "firefox", "moz:firefoxOptions": { "args": [headless ? "-headless" : nil].compact, } } } end |
#start ⇒ Object
Start the driver.
48 49 50 51 52 |
# File 'lib/async/webdriver/bridge/firefox.rb', line 48 def start @process ||= ProcessGroup.spawn(@path, *arguments) super end |
#version ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/async/webdriver/bridge/firefox.rb', line 32 def version ::IO.popen([@path, "--version"]) do |io| return io.read end rescue Errno::ENOENT return nil end |