Firefox
fullPageScreenshot
Captures a screenshot of the entire page.
Firefox command. More details can be found in the official protocol docs.
Usage
browser.fullPageScreenshot()
Returns
- <String> screenshot: The base64-encoded PNG image data comprising the screenshot of the full page.
getMozContext
Get the context that is currently in effect, e.g. CHROME
or CONTENT
.
Firefox command. More details can be found in the official protocol docs.
Usage
browser.getMozContext()
Example
- Asynchronous Mode
- Synchronous Mode
console.log(await browser.getMozContext()); // outputs: 'CHROME'
console.log(browser.getMozContext()); // outputs: 'CHROME'
caution
Synchronous Mode will depcrecated with Node.js v16. With an update to the
underlying Chromium version it became technically impossible to provide the
same synchronous behavior. We recommend to start transition to asynchronous
command execution. For more information, see our <a href="https://github.com/webdriverio/webdriverio/discussions/6702">RFC</a>.
Returns
- <String> Context: The browser context, either
CHROME
orCONTENT
setMozContext
Changes target context for commands between chrome- and content.
Changing the current context has a stateful impact on all subsequent commands. The CONTENT
context has normal web platform document permissions, as if you would evaluate arbitrary JavaScript. The CHROME
context gets elevated permissions that lets you manipulate the browser chrome itself, with full access to the XUL toolkit.
Firefox command. More details can be found in the official protocol docs.
Usage
browser.setMozContext(context)
Parameters
Name | Type | Details |
---|---|---|
context | string | The browser context, either CHROME or CONTENT |
Example
- Asynchronous Mode
- Synchronous Mode
console.log(await browser.getMozContext()); // outputs: 'CHROME'
browser.setMozContext('CONTENT');
console.log(await browser.getMozContext()); // outputs: 'CONTENT'
console.log(browser.getMozContext()); // outputs: 'CHROME'
browser.setMozContext('CONTENT');
console.log(browser.getMozContext()); // outputs: 'CONTENT'
caution
Synchronous Mode will depcrecated with Node.js v16. With an update to the
underlying Chromium version it became technically impossible to provide the
same synchronous behavior. We recommend to start transition to asynchronous
command execution. For more information, see our <a href="https://github.com/webdriverio/webdriverio/discussions/6702">RFC</a>.
installAddOn
Installs a new addon with the current session. This function will return an ID that may later be used to uninstall the addon using uninstallAddon
.
Firefox command. More details can be found in the official protocol docs.
Usage
browser.installAddOn(addon, temporary)
Parameters
Name | Type | Details |
---|---|---|
addon | string | base64 string of the add on file |
temporary | boolean | temporary Flag indicating whether the extension should be installed temporarily - gets removed on restart |
Example
- Asynchronous Mode
- Synchronous Mode
// Create a buffer of the add on .zip file
const extension = await fs.promises.readFile('/path/to/extension.zip')
// Load extension in Firefox
const id = await browser.installAddOn(extension.toString('base64'), false);
// Create a buffer of the add on .zip file
const extension = fs.promises.readFile('/path/to/extension.zip')
// Load extension in Firefox
const id = browser.installAddOn(extension.toString('base64'), false);
caution
Synchronous Mode will depcrecated with Node.js v16. With an update to the
underlying Chromium version it became technically impossible to provide the
same synchronous behavior. We recommend to start transition to asynchronous
command execution. For more information, see our <a href="https://github.com/webdriverio/webdriverio/discussions/6702">RFC</a>.
Returns
- <String> id: A promise that will resolve to an ID for the newly installed addon.
uninstallAddOn
Uninstalls an addon from the current browser session's profile.
Firefox command. More details can be found in the official protocol docs.
Usage
browser.uninstallAddOn(id)
Parameters
Name | Type | Details |
---|---|---|
id | string | id ID of the addon to uninstall. |
Example
- Asynchronous Mode
- Synchronous Mode
// Create a buffer of the add on .zip file
const extension = await fs.promises.readFile('/path/to/extension.zip')
// Load extension in Firefox
const id = await browser.installAddOn(extension.toString('base64'), false);
// ...
await browser.uninstallAddOn(id)
// Create a buffer of the add on .zip file
const extension = fs.promises.readFile('/path/to/extension.zip')
// Load extension in Firefox
const id = browser.installAddOn(extension.toString('base64'), false);
// ...
browser.uninstallAddOn(id)
caution
Synchronous Mode will depcrecated with Node.js v16. With an update to the
underlying Chromium version it became technically impossible to provide the
same synchronous behavior. We recommend to start transition to asynchronous
command execution. For more information, see our <a href="https://github.com/webdriverio/webdriverio/discussions/6702">RFC</a>.