selenium-webdriver/firefox~ Driver

A WebDriver client for Firefox.

Constructor

new Driver()

Methods

getContext() → (non-null) {Promise.<Context>}

Get the context that is currently in effect.

Returns:

Current context.

Type: 
Promise.<Context>

(async) installAddon(path, temporary) → (non-null) {Promise.<string>}

Installs a new addon with the current session. This function will return an ID that may later be used to uninstall the addon.

Parameters:
NameTypeDefaultDescription
pathstring

Path on the local filesystem to the web extension to install.

temporarybooleanfalse

Flag indicating whether the extension should be installed temporarily - gets removed on restart

Deprecated
  • Use #installWebExtension instead.
Returns:

A promise that will resolve to an ID for the newly installed addon.

Type: 
Promise.<string>

(async) installWebExtension(extension, optionsopt) → (non-null) {Promise.<!webExtension.WebExtension>}

Installs a browser extension. Works with remote (Grid) sessions. Uses BiDi when the session has it enabled, and otherwise falls back to geckodriver's classic addon endpoint.

Pass permanent: false to install an unsigned extension; without the option, each transport applies its own default. A directory cannot be installed permanently over BiDi.

Parameters:
NameTypeAttributesDescription
extensionstring

an unpacked extension directory, a packed extension file (.xpi/.zip), or base64-encoded bytes of one.

optionsObject<optional>

permanent keeps the extension installed across browser restarts instead of removing it at shutdown; allowPrivateBrowsing lets it run in private windows.

Throws:
Returns:

the installed extension.

Type: 
Promise.<!webExtension.WebExtension>

setContext(ctxnon-null)

Changes target context for commands between chrome- and content.

Changing the current context has a stateful impact on all subsequent commands. The Context.CONTENT context has normal web platform document permissions, as if you would evaluate arbitrary JavaScript. The Context.CHROME context gets elevated permissions that lets you manipulate the browser chrome itself, with full access to the XUL toolkit.

Use your powers wisely.

Parameters:
NameTypeDescription
ctxPromise.<void>

The context to switch to.

setFileDetector()

This function is a no-op as file detectors are not supported by this implementation.

takeFullPageScreenshot() → (non-null) {Promise.<string>}

Take full page screenshot of the visible region

Returns:

A promise that will be resolved to the screenshot as a base-64 encoded PNG.

Type: 
Promise.<string>

(async) uninstallAddon(id) → (non-null) {Promise}

Uninstalls an addon from the current browser session's profile.

Parameters:
NameTypeDescription
idstring | !Promise.<string>

ID of the addon to uninstall.

Deprecated
  • Use #uninstallWebExtension instead.
Returns:

A promise that will resolve when the operation has completed.

Type: 
Promise

(async) uninstallWebExtension(extensionnon-null) → (non-null) {Promise.<void>}

Uninstalls a browser extension installed with #installWebExtension. Uses BiDi when the session has it enabled, and otherwise geckodriver's classic addon endpoint.

Parameters:
NameTypeDescription
extensionwebExtension.WebExtension

the extension returned by #installWebExtension.

Returns:
Type: 
Promise.<void>

(static) createSession(opt_configopt, opt_executoropt) → (non-null) {Driver}

Creates a new Firefox session.

Parameters:
NameTypeAttributesDescription
opt_configOptions | Capabilities | Object<optional>

The configuration options for this driver, specified as either an Options or Capabilities, or as a raw hash object.

opt_executorhttp.Executor | remote.DriverService<optional>

Either a pre-configured command executor to use for communicating with an externally managed remote end (which is assumed to already be running), or the DriverService to use to start the geckodriver in a child process.

If an executor is provided, care should e taken not to use reuse it with other clients as its internal command mappings will be updated to support Firefox-specific commands.

This parameter may only be used with Mozilla's GeckoDriver.

Throws:

If a custom command executor is provided and the driver is configured to use the legacy FirefoxDriver from the Selenium project.

Type
Error
Returns:

A new driver instance.

Type: 
Driver