Class: Async::WebDriver::Bridge::Firefox

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

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 Firefox browser which need to be provided when requesting a new session.



84
85
86
87
88
89
90
91
92
93
# File 'lib/async/webdriver/bridge/firefox.rb', line 84

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

#pathObject



23
24
25
# File 'lib/async/webdriver/bridge/firefox.rb', line 23

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

#start(**options) ⇒ Object

Start the driver.



77
78
79
# File 'lib/async/webdriver/bridge/firefox.rb', line 77

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

#versionObject



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

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