Class: Async::WebDriver::Bridge::Chrome

Inherits:
Generic
  • Object
show all
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

Methods inherited from Generic

#headless?, #initialize, #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.



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/async/webdriver/bridge/chrome.rb', line 80

def default_capabilities(headless: self.headless?)
	{
		alwaysMatch: {
			browserName: "chrome",
			"goog:chromeOptions": {
				args: [headless ? "--headless=new" : nil].compact,
			},
			webSocketUrl: true,
		},
	}
end

#pathObject



24
25
26
# File 'lib/async/webdriver/bridge/chrome.rb', line 24

def path
	@options.fetch(:path, "chromedriver")
end

#start(**options) ⇒ Object

Start the driver.



73
74
75
# File 'lib/async/webdriver/bridge/chrome.rb', line 73

def start(**options)
	Driver.new(**options).tap(&:start)
end

#versionObject



29
30
31
32
33
34
35
# File 'lib/async/webdriver/bridge/chrome.rb', line 29

def version
	::IO.popen([self.path, "--version"]) do |io|
		return io.read
	end
rescue Errno::ENOENT
	return nil
end