Skip to content

selenium.browser

The generic browser capabilities base and its capability serialization.

PageLoadStrategy

enum PageLoadStrategy: string;

How far a navigation must progress before it is considered complete.

Normal

Normal

Wait for the full document load event.

Eager

Eager

Wait only until the DOM is interactive.

None

None

Return as soon as navigation begins.

UnhandledPromptBehavior

enum UnhandledPromptBehavior: string;

How the driver should treat user prompts that no command handles.

Dismiss

Dismiss

Dismiss the prompt silently.

Accept

Accept

Accept the prompt silently.

DismissAndNotify

DismissAndNotify

Dismiss the prompt and raise an error.

AcceptAndNotify

AcceptAndNotify

Accept the prompt and raise an error.

Ignore

Ignore

Leave the prompt open.

Platform

enum Platform: string;

The requested host platform, mapped to the platformName capability.

Any

Any

No platform constraint.

Windows

Windows

Windows.

Linux

Linux

Linux.

Mac

Mac

macOS.

Android

Android

Android.

Timeouts

struct Timeouts;

Per-session wait limits for commands that may block.

implicit

Duration implicit;

Time to wait for an element to exist when locating.

pageLoad

Duration pageLoad;

Time to wait for page navigation to complete.

script

Duration script;

Time to wait for script evaluation to complete.

Browser

class Browser;

The generic browser capabilities common to every browser.

This base mirrors the W3C standard capabilities and serializes 1:1 to them. The concrete subclasses add vendor capability objects that are not part of W3C.

platform

Platform platform;

Platform to request from the driver.

acceptInsecureCerts

bool acceptInsecureCerts;

Accept insecure TLS certificates.

pageLoadStrategy

PageLoadStrategy pageLoadStrategy;

Page load readiness strategy.

setWindowRect

bool setWindowRect;

Support window resizing and positioning.

strictFileInteractability

bool strictFileInteractability;

Enforce file input interactability checks.

unhandledPromptBehavior

UnhandledPromptBehavior unhandledPromptBehavior;

Strategy for user prompts not handled by commands.

timeouts

Timeouts timeouts;

Session timeout configuration.

name

string name() const;

The browserName capability, empty for a generic browser.

generic

bool generic() const;

Whether this is the generic base rather than a named browser.

driverArgs

string[] driverArgs() const;

Extra service arguments to pass when launching the WebDriver process.

A hook for subclasses to wire process-level features into the bridge. The base returns none.

driverCapacity

int driverCapacity() const;

Maximum sessions allowed on a locally spawned bridge, or zero for unlimited sessions.

normalizeLogger

void normalizeLogger(Logger logger);

Folds this browser's logging preferences upward into the session logger.

The base is a no-op. Subclasses with logging capabilities override it so their levels accumulate on the shared Logger.

Parameters:

Name Description
Logger logger The session logger to normalize into.

isInstalled

bool isInstalled();

Whether a matching WebDriver binary can be found on PATH.

resolveBinary

string resolveBinary(bool throwOnNotFound = true);

Resolves the WebDriver binary for this browser on PATH.

A named browser resolves its specific driver, while a generic browser scans the known drivers and returns the first one present.

Parameters:

Name Description
bool throwOnNotFound Whether to throw when no binary is found.

Returns: The resolved binary path, or null when none is found and throwing is disabled.

Throws: WebDriverConnectionException if no binary is found and throwOnNotFound is true.

toJSON

JSONValue toJSON() const;

Serializes the standard W3C capabilities, omitting fields left at default.

fromJSONValue

static Browser fromJSONValue(JSONValue json);

Builds the most specific browser subclass from a capabilities object.

Chrome and Edge are detected by the presence of their vendor options keys rather than browserName, so a browser configured with only standard capabilities or logging prefs will round-trip as the generic base instead of the concrete subclass.

Parameters:

Name Description
JSONValue json The capabilities object to parse.

Returns: A browser instance of the detected concrete type.

parseFrom

protected void parseFrom(JSONValue json);

Populates the standard W3C capability fields from a capabilities object.