What a plugin learns about a browser before it starts, and what it may change.
The set checks every plugin against a LaunchContext; before_launch gets the
browser’s LaunchSettings, which the host turns into the engine’s own options
after every plugin has run. Items are in seleniumbase_rs_plugin, defined in
crates/seleniumbase-rs-plugin/src/lib.rs.
LaunchContext#
struct seleniumbase_rs_plugin::LaunchContext
What the set checks a plugin against before a browser starts, in
PluginSet::check and check_with. It is not
#[non_exhaustive], so a test builds one with a struct literal.
The engine that will run the browser.
The browser’s family. Requirements::CHROMIUM_ONLY refuses any other than
Chromium.
Whether the browser runs without a window. Requirements::HEADFUL refuses
true.
Whether the program attaches to a running browser instead of starting one.
Requirements::LAUNCH_ONLY refuses true.
What the hosts of seleniumbase-rs pass:
| Where | engine | family | headless | connecting |
|---|---|---|---|---|
Pure CDP, Browser::launch | Cdp | Chromium | the options’ headless setting | false |
Pure CDP, Browser::connect_with_plugins | Cdp | Chromium | whether the user agent of /json/version holds HeadlessChrome | true |
WebDriver, BrowserSession::connect | WebDriver | from BrowserConfig::browser | the headless setting; always false for Safari | true when the WebDriver URL is not the local default |
WebDriver, a server that answers browserName: tauri | WebDriver | Embedded | false | true |
A launch checks the set twice, before and after before_launch, because a
plugin may change what another was checked against, such as headless mode.
LaunchSettings#
struct non_exhaustive seleniumbase_rs_plugin::LaunchSettings
The start-up settings a plugin may change in
before_launch. After each plugin,
PluginSet::before_launch compares the settings with what they were and refuses
a change the plugin may not make, as PluginError::Capability or
PluginError::Sealed. Outside the crate, start from LaunchSettings::default()
and assign the fields.
Command-line switches for the browser, such as --lang=de. Adding needs
launch.args; entries may not be removed. A switch of
REFUSED_SWITCHES, and a
--disable-features= or --enable-features= that names a refused feature,
is refused unless the plugin holds raw:switches.
Browser preferences, as in Chrome’s Preferences file. Changing needs
launch.prefs; a key that is there may not be removed (it removed a preference another plugin set). The pure CDP engine reads a dotted name such
as intl.accept_languages as a path, as LaunchOptionsBuilder::preference
does.
Unpacked extension folders to load. Adding needs launch.extensions; entries
may not be removed.
The proxy server, such as http://127.0.0.1:8080. Changing needs
launch.proxy. The host shows the server only: a password in the launch
options is never shown to plugins, and it stays when they leave the proxy as
it is. Seals::PROXY can seal it.
Whether the browser runs without a window. Changing needs launch.headless.
Seals::HEADLESS can seal it.
Host-resolver rules; the host joins them into one --host-resolver-rules
switch. Changing needs launch.network; entries may not be removed.
The WebRTC IP-handling policy. Changing needs launch.network.
Seals::WEBRTC can seal it.
Features to disable; the host merges them into one --disable-features
switch. Adding needs launch.args; entries may not be removed;
IsolateOrigins and site-per-process are refused unless the plugin holds
raw:switches.
Features to enable, merged into one --enable-features switch. The same rules
as disable_features.
Whether to turn QUIC off (--disable-quic). Changing needs launch.network.
CapabilitySet::legacy(), the grants of a plugin that declares no metadata,
holds launch.args, launch.prefs, launch.headless, launch.proxy and
launch.extensions but not launch.network: such a plugin may not change
host_resolver_rules, webrtc_policy or disable_quic.
What each engine fills in and applies#
| Host | Fills in | Applies |
|---|---|---|
| Pure CDP | Every field from the LaunchOptions: extra arguments, preferences, extensions, the proxy’s server, headless, host rules, features, QUIC, WebRTC policy, and the profile | Every field back into the options. A proxy that does not parse is SeleniumBaseError::InvalidConfig. WebRtcPolicy::Default adds no switch |
| WebDriver, Chromium | extra_args; the prefs of goog:chromeOptions (ms:edgeOptions for Edge); the folders of extension_dir; the proxy without its password; headless. The other fields start empty | args become extra_args; host rules, features, WebRTC policy and QUIC become one switch each, merged with one already there; extensions become extension_dir (each path UTF-8 and without a comma) |
| WebDriver, Firefox | The arguments and preferences of the Firefox options; headless | Arguments and preferences. Host rules, WebRTC policy, features, QUIC, extensions and a proxy are refused; a preference must be a boolean, a whole number or text |
| WebDriver, Safari | Headless only, always false | Any change of arguments, preferences, extensions, proxy, headless or the Chromium-only fields is refused |
A refusal on Firefox or Safari is SeleniumBaseError::Plugin (a plugin's before_launch asked for what Firefox cannot do here: ...). The guide has the
details per browser: The WebDriver engine.
LaunchSettings::profile#
fn seleniumbase_rs_plugin::LaunchSettings::profile
The browser profile this launch uses, read-only for plugins.
The hosts show ProfileView::Persistent(folder) when the launch names a
profile folder (user_data_dir), and ProfileView::Ephemeral otherwise.
LaunchSettings::set_profile#
fn seleniumbase_rs_plugin::LaunchSettings::set_profile
The profile of the launch.
For the host, before the plugins run. A plugin that calls it is refused after
its hook: PluginError::Capability on profile, the profile is read-only for plugins.
ProfileView#
enum non_exhaustive seleniumbase_rs_plugin::ProfileView
Engine#
enum non_exhaustive seleniumbase_rs_plugin::Engine
Which of seleniumbase-rs’s engines runs the browser. A plugin reads it from
LaunchContext::engine, BrowserHandle::engine and PageHandle::engine.
BrowserFamily#
enum non_exhaustive seleniumbase_rs_plugin::BrowserFamily
The family of the browser a plugin runs with.
The WebDriver engine refuses plugins for Internet Explorer, which is none of
these families, with SeleniumBaseError::Plugin.
WebRtcPolicy#
enum non_exhaustive seleniumbase_rs_plugin::WebRtcPolicy
Chrome’s WebRTC IP-handling policies, the value of
LaunchSettings::webrtc_policy. Both engines turn it into one
--force-webrtc-ip-handling-policy switch.
A policy added to the API later, which this version of seleniumbase-rs cannot
apply, is SeleniumBaseError::InvalidConfig.