Class: Async::WebDriver::Bridge::Chrome
- Defined in:
- lib/async/webdriver/bridge/chrome.rb
Overview
A bridge to the Chrome browser using ‘chromedriver`.
“‘ ruby begin bridge = Async::WebDriver::Bridge::Chrome.start client = Async::WebDriver::Client.open(bridge.endpoint) ensure bridge&.close end “`
Defined Under Namespace
Classes: Driver
Instance Method Summary collapse
-
#default_capabilities(headless: self.headless?) ⇒ Object
The default capabilities for the Chrome browser which need to be provided when requesting a new session.
- #path ⇒ Object
-
#start(**options) ⇒ Object
Start the driver.
- #version ⇒ Object
Methods inherited from Generic
#headless?, #initialize, start, #supported?
Constructor Details
This class inherits a constructor from Async::WebDriver::Bridge::Generic
Instance Method Details
#default_capabilities(headless: self.headless?) ⇒ Object
The default capabilities for the Chrome browser which need to be provided when requesting a new session.
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/async/webdriver/bridge/chrome.rb', line 74 def default_capabilities(headless: self.headless?) { alwaysMatch: { browserName: "chrome", "goog:chromeOptions": { args: [headless ? "--headless" : nil].compact, }, webSocketUrl: true, }, } end |
#path ⇒ Object
23 24 25 |
# File 'lib/async/webdriver/bridge/chrome.rb', line 23 def path @options.fetch(:path, "chromedriver") end |
#start(**options) ⇒ Object
Start the driver.
67 68 69 |
# File 'lib/async/webdriver/bridge/chrome.rb', line 67 def start(**) Driver.new(**).tap(&:start) end |
#version ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/async/webdriver/bridge/chrome.rb', line 28 def version ::IO.popen([self.path, "--version"]) do |io| return io.read end rescue Errno::ENOENT return nil end |