Repository navigation
Browsers & Drivers
The browser is launched when a Huzzah::Role is instantiated. You can access the browser from any Huzzah class by calling the browser method:
# Role
# Launch the Browser
user = Huzzah::Role.new
# Access the browser through a Role
user.browser
# Access the browser through a Site
user.moolah.browser
# Access the browser through a Page
user.moolah.login_page.browser
# Access the browser through a Partial
user.moolah.user_account.header.browser
# Access the browser through a Flow
user.payment.browserHuzzah supports a basic firefox (and defaults to it) driver out of the box. The same as calling:
Watir::Browser.new(:firefox)You can access the underlying Selenium driver by calling:
user.browser.driverYou can define a custom driver as follows:
Huzzah.define_driver(:chrome) do
Watir::Browser.new(:chrome)
endNOTE: This example assumes that you have chromedriver properly installed.
You can define as many drivers as you wish and they can be a complicated as you need them to be. Any type of profile or capabilities configuration that you can do with watir-webdriver, you can do within the Huzzah.define_driver block. The only caveat is that the last line of your block needs to return the browser instance. The block is not called until a role is instantiated.
Huzzah.define_driver(:custom_firefox) do
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 120
profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.fixup.alternate.enabled'] = false
profile['network.dns.disablePrefetch'] = true
profile['network.http.connect.timeout'] = 120
profile['network.http.request.timeout'] = 120
driver = Selenium::WebDriver.for(:firefox, profile: profile)
Watir::Browser.new(driver)
endYou can set an overall default driver within the Huzzah.config block. See Configuration
You can also set a driver per role. This is done within the role's YAML file:
---
dev:
:email: 'dedric.auer@howe.com'
:password: 'U9HhGbSp'
:full_name: 'Dedric Auer'
:driver: 'chrome'When a new role is instantiated, Huzzah will check to see if a the driver has been specified in the role's YAML file. Otherwise, it will fall back to the default driver defined in the configuration block.