Async::WebDriver SourceAsyncWebDriverBridgeFirefox

class Firefox

A bridge to the Firefox browser using geckodriver.

begin
	bridge = Async::WebDriver::Bridge::Firefox.start
	client = Async::WebDriver::Client.open(bridge.endpoint)
ensure
	bridge&.close
end

Nested

Definitions

def version

Signature

returns String

The version of the geckodriver executable.

Implementation

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

def start(**options)

Start the driver.

Implementation

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

def default_capabilities(headless: self.headless?)

The default capabilities for the Firefox browser which need to be provided when requesting a new session.

Signature

parameter headless Boolean

Whether to run the browser in headless mode.

returns Hash

The default capabilities for the Firefox browser.

Implementation

def default_capabilities(headless: self.headless?)
	{
		alwaysMatch: {
			browserName: "firefox",
			"moz:firefoxOptions": {
				args: [headless ? "-headless" : nil].compact,
			}
		}
	}
end