Module: Async::WebDriver::Bridge

Defined in:
lib/async/webdriver/bridge.rb,
lib/async/webdriver/bridge/pool.rb,
lib/async/webdriver/bridge/chrome.rb,
lib/async/webdriver/bridge/driver.rb,
lib/async/webdriver/bridge/safari.rb,
lib/async/webdriver/bridge/firefox.rb,
lib/async/webdriver/bridge/generic.rb,
lib/async/webdriver/bridge/process_group.rb

Overview

A bridge is a process that can be used to communicate with a browser. It is not needed in all cases, but is useful when you want to run integration tests without any external drivers/dependencies. As starting a bridge can be slow, it is recommended to use a shared bridge when possible.

Defined Under Namespace

Classes: Chrome, Driver, Firefox, Generic, Pool, ProcessDriver, ProcessGroup, Safari, UnsupportedError

Constant Summary collapse

ALL =
[
	Bridge::Chrome,
	Bridge::Firefox,
	Bridge::Safari,
]
ASYNC_WEBDRIVER_BRIDGE =

The environment variable used to select a bridge.

“‘ ASYNC_WEBDRIVER_BRIDGE=Chrome ASYNC_WEBDRIVER_BRIDGE=Firefox “`

"ASYNC_WEBDRIVER_BRIDGE"
ASYNC_WEBDRIVER_BRIDGE_HEADLESS =

The environment variable used to disable headless mode.

“‘ ASYNC_WEBDRIVER_BRIDGE_HEADLESS=false “`

"ASYNC_WEBDRIVER_BRIDGE_HEADLESS"

Class Method Summary collapse

Class Method Details

.default(env = ENV, **options) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/async/webdriver/bridge.rb', line 56

def self.default(env = ENV, **options)
	if env[ASYNC_WEBDRIVER_BRIDGE_HEADLESS] == "false"
		options[:headless] = false
	end
	
	if name = env[ASYNC_WEBDRIVER_BRIDGE]
		self.const_get(name).mew(**options)
	else
		ALL.each do |klass|
			instance = klass.new(**options)
			return instance if instance.supported?
		end
		
		raise UnsupportedError, "No supported bridge found!"
	end
end

.each(&block) ⇒ Object

Iterate over supported bridge implementations.



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

def self.each(&block)
	return enum_for(:each) unless block_given?
	
	ALL.each do |klass|
		next unless klass.new.supported?
		yield klass
	end
end