butterbee/config/browser
This module provides functionality for parsing and creating browser configurations from TOML configuration files for WebDriver BiDi sessions.
Chromium support
Because chromium does not natively support WebDriver BiDi, butterbee uses the chromedriver to control chromium. Which has a BiDi to CDP mapper built in.
Chromedriver does not come with chromium built in, so make sure you have chromium installed. Chromedriver will search for the chromium binary on your system. so no additional configuration is needed.
TOML Configuration Format
The browser configuration is defined under the
[tools.butterbee.browser] section of your gleam.toml file:
# gleam.toml
[tools.butterbee.browser.firefox]
cmd = "firefox"
flags = ["-headless"]
host = "127.0.0.1"
[tools.butterbee.browser.chromium]
cmd = "chromedriver"
flags = []
host = "127.0.0.1"
Headless
to run the browsers headless, add the following to your gleam.toml file:
[tools.butterbee.browser.firefox]
flags = ["-headless"]
[tools.butterbee.capabilities.always_match]
webSocketUrl = true
"goog:chromeOptions" = { args = ["--headless=new"] }
Types
pub type BrowserConfig {
BrowserConfig(
start_url: String,
cmd: String,
extra_flags: List(String),
host: String,
)
}
Constructors
-
BrowserConfig( start_url: String, cmd: String, extra_flags: List(String), host: String, )Arguments
- start_url
-
The url that is loaded when the browser is started.
- cmd
-
The path to the browser executable, or the name of the browser if it is in the PATH.
- extra_flags
-
Extra flags to pass to the browser.
- host
-
The host to use for the browser.
pub type BrowserType {
Firefox
Chromium
}
Constructors
-
Firefox -
Chromium
Values
pub fn default() -> dict.Dict(BrowserType, BrowserConfig)
Returns the default browser configuration
pub const default_browser_type: BrowserType
Returns the default browser type, firefox
pub fn default_configuration(
browser_type: BrowserType,
) -> BrowserConfig
pub fn with_cmd(
config: BrowserConfig,
cmd: String,
) -> BrowserConfig
pub fn with_extra_flags(
config: BrowserConfig,
extra_flags: List(String),
) -> BrowserConfig
pub fn with_host(
config: BrowserConfig,
host: String,
) -> BrowserConfig
pub fn with_start_url(
config: BrowserConfig,
start_url: String,
) -> BrowserConfig