---
title: Automated Browser Extension Testing | Testing Resources
description: How to install and drive a browser extension end to end, with working
  examples for Selenium, Puppeteer and Playwright on the major browsers.
source_url:
  html: https://testingbot.com/resources/articles/automated-browser-extension-testing
  md: https://testingbot.com/resources/articles/automated-browser-extension-testing.md
---

![Automated Browser Extension Testing](https://testingbot.com/assets/resources/articles/36.webp)

# End-to-end testing of browser extensions

How to install and drive a browser extension end to end, with working examples for Selenium, Puppeteer and Playwright on the major browsers.

By [Jochen D.](https://testingbot.com/about/jochen-d)2024-02-21Updated 2026-08-31

 Share on Facebook 

 Share on Twitter 

 Post on Reddit 

 Share link 

Selenium is a browser automation framework that allows you to test websites on multiple browsers. One common use case for running browser tests is to test browser extensions. Browser extensions are programs that you can install in your browser to extend its functionality. Next to Selenium, both [Puppeteer](https://testingbot.com#puppeteer) and [Playwright](https://testingbot.com#playwright) also provide functionality to install and test browser extensions.

All major browsers support extensions: Chrome through its [Chrome Web Store](https://chromewebstore.google.com/), Microsoft Edge with their [Edge Extensions](https://microsoftedge.microsoft.com/addons/Microsoft-Edge-Extensions-Home), Firefox with [Firefox Addons](https://addons.mozilla.org/en-GB/firefox/extensions/) and [Safari Extensions](https://support.apple.com/en-us/102343).

> TestingBot provides its own Browser Extension which can be installed on your [Chrome](https://chrome.google.com/webstore/detail/testingbot/nhjmiaiamlfblfagaodhkeabfbnmdmff) or [Firefox](https://addons.mozilla.org/addon/testingbot/) browser, for free. It allows you to easily test your website(s) on multiple browsers.

## Table of Contents

- [Installing a Browser Extension with Selenium](https://testingbot.com#install)
- [Running tests against a Browser Extension with Selenium](https://testingbot.com#run)
- [Puppeteer for extension testing](https://testingbot.com#puppeteer)
- [Playwright for extension testing](https://testingbot.com#playwright)

## Installing a Browser Extension with Selenium

Before you can start testing on a browser extension, you will first have to instruct the browser you are using to test, to install the extension. The way you install an extension automically depends on the browser you are using.

### Using TestingBot

TestingBot has created a very easy way to make sure a browser extension is installed before starting an automated test. You can simply zip the files required for the extension (for example a `.crx`, `.xpi`, `.safariextz` or Safari Web Extension) and specify a custom [load-extension capability](https://testingbot.com/support/web-automate/selenium/browser-extension) to instruct the TestingBot browsers to install the extension.

As soon as the Selenium web test starts, you will see that the extension is preloaded in the browser.

### Adding a browser extension with your Selenium test

If you are running a test locally, you can specify these two flags for Chrome-based tests:

- `--load-extension=...path-to-extension...`
- `--disable-extensions-except=...path-to-extension...`

For Firefox tests, you can add an addon to a custom Firefox profile:

```java
FirefoxProfile profile = new FirefoxProfile();
profile.addExtension(new File("testingbot.xpi"));
options.setProfile(profile);
```

If you don't want to use the profile option, there's also a specific geckodriver URL that you can use that will accomplish the same thing:

```bash
curl -X POST http://127.0.0.1/session/../moz/addon/install' -d '{"path":"...","temporary":true}'
```

With Safari, it is much more difficult to automatically install a browser extension. To do this, you will need to use AppleScript (osascript) to instrument Safari and have it install the extension.

Edge has a [addExtensions](https://www.selenium.dev/documentation/webdriver/browsers/edge/#add-extensions) method to use packed extensions(`.crx` files) or use `load-extension=...` for [unpacked extensions](https://chromedriver.chromium.org/extensions#h.p_ID_36).

## Running tests against a Browser Extension with Selenium

Selenium allows you to automate the browser, by providing functionality such as navigating to a page, checking the contents, clicking elements, etc. It is however not possible to interact with elements outside of the actual webview of the browser. This means you can not click the extension in the browser toolbar and interact with the extension's UI.

A solution to still perform automated testing against browser extension is to load the extension as a URL. These extensions can then be tested, by instructing your [Selenium WebDriver](https://testingbot.com/support/web-automate/selenium) test to open the extension's page. This way you can perform automated UI testing for browser plugins.

### Testing Chrome Extensions

For example, on Chrome you would open the URL with the unique identifier of the extension you want to test: `chrome-extension://<id>/index.html`.

Please see the example below on how to run a sample Selenium test on TestingBot with a Chrome extension. TestingBot will install the extension and your test will open the extension's popup page to perform verifications.

```javascript
const webdriver = require('selenium-webdriver');
const capabilities = {
 'platform' : 'WIN10',
 'browserName' : 'chrome',
 'version' : 'latest',
 'load-extension': 'https://...path..to..extension'
}
async function runTest () {
  let driver = new webdriver.Builder()
    .usingServer('https://api_key:api_secret@hub.testingbot.com/wd/hub')
    .withCapabilities(capabilities)
    .build();
  await driver.get('chrome-extension://paaamahlcokbnafoiahanekijojkhbdm/popup/index.html');
  const element = await driver.findElement(By.css('#environments'));
  const isElementDisplayed = await element.isDisplayed();
  if (isElementDisplayed) {
    console.log('Element is present on the page.');
  } else {
    console.log('Element is not present on the page.');
  }
  await driver.quit();
}
runTest();
```

> To learn more about testing extensions and the extension id, please see [end-to-end testing of Chrome extensions](https://developer.chrome.com/docs/extensions/how-to/test/end-to-end-testing#set-extension-id).

### Testing Firefox Addons

Just as you would test a Chrome extension, you can open the Firefox addon in a new tab by utilizing the `moz-extension` scheme.

```bash
moz-extension://3d9b1639-77fb-44a1-888a-6d97d773e96b/popup/index.html
```

Once the Firefox addon is loaded, your test can interact with it.

Please see the example below on how to run a sample Selenium test on TestingBot with a Chrome extension. TestingBot will install the extension and your test will open the extension's popup page to perform verifications.

```javascript
const webdriver = require('selenium-webdriver');
const capabilities = {
 'platform' : 'WIN10',
 'browserName' : 'firefox',
 'version' : 'latest',
 'load-extension': 'https://...path..to..extension'
}
async function runTest () {
  let driver = new webdriver.Builder()
    .usingServer('https://api_key:api_secret@hub.testingbot.com/wd/hub')
    .withCapabilities(capabilities)
    .build();
  await driver.get('moz-extension://3d9b1639-77fb-44a1-888a-6d97d773e96b/popup/index.html');
  const element = await driver.findElement(By.css('#environments'));
  const isElementDisplayed = await element.isDisplayed();
  if (isElementDisplayed) {
    console.log('Element is present on the page.');
  } else {
    console.log('Element is not present on the page.');
  }
  await driver.quit();
}
runTest();
```

### Testing Safari Extensions

TestingBot allows you to upload your (unsigned) Safari Web Extension and have this extension installed and activated at the start of your Safari test. You can then test any website with the extension loaded, and even perform [UI tests against your Safari Web Extension](https://testingbot.com/support/web-automate/selenium/browser-extension#safari-ui).

More information available in the [Safari Web Extension Testing](https://testingbot.com/support/web-automate/selenium/browser-extension#safari) documentation.

> The older `.safariextz` based extensions can be tested as well, on Safari 12 or lower.

## Using Puppeteer for extension testing

Puppeteer allows for [testing Chrome extensions](https://pptr.dev/guides/chrome-extensions). Please see the example below on how to do this.

```javascript
import puppeteer from 'puppeteer';
import path from 'path';

(async () => {
  const pathToExtension = path.join(process.cwd(), 'testingbot-extension');
  const browser = await puppeteer.launch({
    headless: 'new',
    args: [
      `--disable-extensions-except=${pathToExtension}`,
      `--load-extension=${pathToExtension}`,
    ],
  });
  const backgroundPageTarget = await browser.waitForTarget(
    target => target.type() === 'background_page'
  );
  const backgroundPage = await backgroundPageTarget.page();
  await browser.close();
})();
```

This will instruct the local (headless) Chrome browser to load the specified extension. It will then wait for the background page to be available.

Similar to the [Selenium + Chrome extension example](https://testingbot.com#testing-chrome-extension), you can also open the extension's page using Puppeteer and interact with the page.

### Remote Puppeteer Browser Extension Testing

TestingBot provides [Browser Extension Testing with Puppeteer](https://testingbot.com/support/web-automate/puppeteer/browser-extension-testing). First upload your Chrome extension to TestingBot storage, then use the `load-extension` capability to instruct the remote Chrome browser to use the extension.

## Using Playwright for browser extension testing

TestingBot provides [Playwright Browser Extension Testing](https://testingbot.com/support/web-automate/playwright/browser-extension-testing) on Chrome, Edge and Firefox. Simply provide the `load-extension` capability to test on a remote browser that has your extension installed and activated.

For Chromium based browsers, your test script will need to use CDP to connect to the remote browser. This is currently the only limitation, because of how [Playwright](https://testingbot.com/support/web-automate/playwright) handles profiles.

```javascript
const pw = require('playwright-core')

(async () => {
  const tbCapabilities = {
    browserName: 'firefox',
    platform: 'LINUX',
    key: process.env.TB_KEY,
    secret: process.env.TB_SECRET,
   'load-extension': 'tb://path-to-extension',
   'firefoxExtensionMap': {
      'addon@testingbot.com': '3d9b1639-77fb-44a1-888a-6d97d773e96b'
    }
  }
  const wsEndpoint = `wss://cloud.testingbot.com/playwright?capabilities=${encodeURIComponent(
    JSON.stringify(tbCapabilities)
  )}`;

  const browser = await pw.chromium.connect({
    wsEndpoint
  })
  const context = await browser.newContext()
  const page = await context.newPage()

  await page.goto('moz-extension://3d9b1639-77fb-44a1-888a-6d97d773e96b/src/pages/popup/index.html')

  await browser.close()
})();
```

> To run UI tests against a Firefox extension, please supply `firefoxExtensionMap` to set the UUID of the extension to a fixed value. You can then use this same value with `moz-extension://` to start testing the UI of your extension.

Topics [Web Testing](https://testingbot.com/resources/articles/topic/web-testing) 

## Sidebar

### TestingBot Cloud Testing

Run automated, manual and visual tests on remote browsers and devices. Sign up for a free trial.

[Free Trial](https://testingbot.com/users/sign_up)

### Latest articles

[![Fake Webcam and Microphone in Chrome for Selenium Tests](https://testingbot.com/assets/resources/articles/40-6133f19cdc01c7d6461f3f138789185ede755adf911eb2da670961ba41fcce30.webp)](https://testingbot.com/resources/articles/fake-webcam-microphone-chrome)

#### [Fake Webcam and Microphone in Chrome for Selenium Tests](https://testingbot.com/resources/articles/fake-webcam-microphone-chrome)

How to feed Chrome a fake webcam and microphone during au...

[Read article →](https://testingbot.com/resources/articles/fake-webcam-microphone-chrome)

[![Testing Tailwind CSS webpages](https://testingbot.com/assets/resources/articles/26-90e656f61416f2cfe616ab4bca7b673554e4fd05702863d3274ac8ab06a00c95.webp)](https://testingbot.com/resources/articles/tailwind-testing)

#### [Testing Tailwind CSS webpages](https://testingbot.com/resources/articles/tailwind-testing)

How to write automated tests against a Tailwind CSS site ...

[Read article →](https://testingbot.com/resources/articles/tailwind-testing)

[![Internationalization testing of websites and mobile apps](https://testingbot.com/assets/resources/articles/15-4127c39c1b9ffddd30ae0a465903d841df9fbbd87f39dbef0f260ab101340123.webp)](https://testingbot.com/resources/articles/internationalization-testing)

#### [Internationalization testing of websites and mobile apps](https://testingbot.com/resources/articles/internationalization-testing)

Learn more about Internationalization Testing: how to pre...

[Read article →](https://testingbot.com/resources/articles/internationalization-testing)

## Other Articles

[![Automated Testing with Puppeteer](https://testingbot.com/assets/resources/articles/11-416015eb394d928299663409dccd67993b0a664f4b3ff456803fefc6bf1f325a.webp)](https://testingbot.com/resources/articles/automated-testing-with-puppeteer "Automated Testing with Puppeteer")

### [Automated Testing with Puppeteer](https://testingbot.com/resources/articles/automated-testing-with-puppeteer)

Puppeteer combined with a test framework provides a great way to run automated browser tests. Follow this guide for more information.

[Read article →](https://testingbot.com/resources/articles/automated-testing-with-puppeteer)

[![Handling Captcha during Automated Testing](https://testingbot.com/assets/resources/articles/7-b54c5d487c7cc09e40ed52a5c59ecc06e26e172e66e215a8f7fb3e6c7d1c1de3.webp)](https://testingbot.com/resources/articles/automated-testing-with-captcha "Handling Captcha during Automated Testing")

### [Handling Captcha during Automated Testing](https://testingbot.com/resources/articles/automated-testing-with-captcha)

Practical ways to get an automated test past a captcha: disable it in staging, click the reCaptcha checkbox, or solve it by hand mid-run.

[Read article →](https://testingbot.com/resources/articles/automated-testing-with-captcha)

[![Parallel Testing: What Actually Scales](https://testingbot.com/assets/resources/articles/parallel-testing-32f51791d748c85621c4bf431293e46349cf0d81ec1a3262450b33f0edead4ef.webp)](https://testingbot.com/resources/articles/parallel-testing "Parallel Testing: What Actually Scales")

### [Parallel Testing: What Actually Scales](https://testingbot.com/resources/articles/parallel-testing)

Why adding workers stops helping, how to shard so they are not idle, and what breaks the first time a suite runs concurrently.

[Read article →](https://testingbot.com/resources/articles/parallel-testing)

[![Automated Regression Testing in CI](https://testingbot.com/assets/resources/articles/automated-regression-testing-e283d0b6a88c787633d29f0cfb35cbb90a48136dace54720252843ebc4a36063.webp)](https://testingbot.com/resources/articles/automated-regression-testing "Automated Regression Testing in CI")

### [Automated Regression Testing in CI](https://testingbot.com/resources/articles/automated-regression-testing)

How to build a regression suite that stays fast and trustworthy in CI, what to leave out of it, and when to run which part.

[Read article →](https://testingbot.com/resources/articles/automated-regression-testing)

## Ready to start testing?
[Start a free trial](https://testingbot.com/users/sign_up)
