How to test Chrome extensions in Selenium

On This Page Why Use Chrome Driver to try a Chrome extension with Selenium?January 06, 2026 · 6 min read · Tool Comparison

How to try Chrome extensions in Selenium

With and Continuous Delivery (CD) becoming standard practices in, has been shew as a key portion in screen processes. are consciously and ceaselessly geared towards mechanization, with the aim of making testing faster, easier and more accurate.

However, there are certain activeness that can be more difficult to automate. For example, automating the testing of browser extensions can pose difficulties.

This article attempts to explore those difficulties and provide a few solutions.

Why Use Chrome Driver to test a Chrome extension with Selenium?

Before acquire into realize how you can test a Chrome extension employ Selenium, you should have an idea of what a ChromeDriver is and why it is required.

ChromeDriver is a tool for enable automated test scripts to control the Google Chrome browser.

It serves as a bridge between the Selenium WebDriver model and the Chrome browser. Since Selenium does not directly control browsers, it mail commands via a

browser-specific driver. The ChromeDriver translates Selenium ’ s commands for Chrome to realize.

How to Set up Chrome Driver

Here are the steps that you can postdate to instal Chrome Driver

Step 1: Check Your Google Chrome Version: Visit chrome: //settings/help and observe the version turn (e.g., 136.0.7103.48).

Step 2: Download the Matching ChromeDriver: Visithttps: //chromedriver.chromium.org/downloads, select the version that matches your Chrome browser, and download the file for your operating system:

  • .zip file for Windows
  • .tar.gz or .zip for macOS/Linux

Step 3: Extract the File: Unzip the download file to find the chase:

  • chromedriver.exe on Windows
  • chromedriver binary on macOS/Linux

Step 4: Move ChromeDriver to a System Path Folder

For Windows:

  • Create a pamphlet like C: \WebDriver\bin.
  • Move chromedriver.exe into it.
  • Add that folder to your System PATH:
  • Go to System Properties & gt; Environment Variables.
  • Under System Variables, Path & gt; Edit & gt; Add C: \WebDriver\bin.

For macOS/Linux:

Exposed Terminal and run:

sudo mv chromedriver /usr/local/bin/ sudo chmod +x /usr/local/bin/chromedriver

Step 5: Verify Installation:

Open a end or command prompt to input:

chromedriver -- version

Once this is entered you ’ d see:

ChromeDriver 123.0.6312.86

With this, the Chrome Driver is all set to be used with Selenium.

Read More:

How to test a Chrome extension with Selenium?

1. Download Chrome Extension

Get the webstore URL or extension ID from Google Web Store. Now enter the URL/ID into the main battlefield on this page:https: //chrome-extension-downloader.com/

Click Download. Save the CRX file. Store the file in the same location as your handwriting.

Note: The CRX might be a local file that has not yet been uploaded to the Chrome Web Store. In causa the extension does not survive in the web shop, instal it manually by dragging the CRX file into theChrome: //extensionspage and clicking ‘ Add ’. Find more details on this operationhere.

2. Download theChrome Extension Source Viewerfrom the Google Web Store.

3. View source of the CRX file

Go to the Chrome Extensions in the Google Web Store. Click the yellow icon in the browser. Go to View Source. If the CRX file is not displayed in the Web Store, the origin file can be viewed manually. Just clickhereand upload the CRX file.

A tilt of all imagination (javascript, images, etc.) and pages available in the CRX should be displayed.

4. Identify the page to be try

To locate a specific page, extract the unique ID of the CRX in the Chrome Extension. Here ’ s how.

  • First, get the unique ID of the Chrome Extension. Right-click on it and selectOptions.
  • The user will be place to their unique ID page URL:chrome-extension: //UNIQUEID/options.html
  • Go back to the CRX resource list. Select the specific page for testing:SPECIFICPAGE.HTML.
    Change options.html with the specific page on the unique URL. Example:
    Change chrome-extension: //UNIQUEID/options.html to chrome-extension: //UNIQUEID/SPECIFICPAGE.html
  • Copy this URL. It will be required later in the Webdriver code.

5. Initiate Selenium script to create a new ChromeDriver

Enter the Chrome Extension into ChromeDriver. is a standalone server that implements WebDriver ’ s wire protocol. To do this, new codification needs to be added to the beginning of the playscript when creating the browser object.

Here ’ s the syntax for this codification in a number of languages much apply in scripts:

Java

For autonomous testing across multiple user personas, check out SUSATest — it explores your app like 10 different real users.

ChromeOptions selection = new ChromeOptions (); options.addExtensions (new File (`` /path/to/extension.crx '')); DesiredCapabilities capabilities = new DesiredCapabilities (); capabilities.setCapability (ChromeOptions.CAPABILITY, selection); ChromeDriver driver = new ChromeDriver (capabilities);

Python

chop = webdriver.ChromeOptions () chop.add_extension (EXTENSION_PATH) # create new Chrome driver object with Chrome propagation driver = webdriver.Chrome (chrome_options=chop)

Javascript

var chromeOptions = webdriver.Capabilities.chrome (); chromeOptions: [binary: '/Applications/GoogleChrome.app/Contents/MacOS/Google Chrome ', args: [], extensions: ['EXTENSION_LOCATION.crx ']] var driver = new webdriver.Builder (). withCapabilities (chromeOptions). build ();

PHPunit

//Setting extensions is also optional $ options- & gt; addExtensions (array ('extension_location.crx ',)); $ cap = DesiredCapabilities: :chrome (); $ caps- & gt; setCapability (ChromeOptions: :CAPABILITY, $ options); $ driver = RemoteWebDriver: :create ($ url, $ caps);

6. Navigate to The ChromeDriver Website Page

The syntax to do this is below:

driver.get ('chrome-extension: //UNIQUEID/SPECIFICPAGE.html ');

After doing this, the examiner can interact with and prove the extension as they would a normal HTML webpage.

Often, an iFrame will be included in the HTML file. Switching the focus to the iFrame is easy, depicted in the examples below:

PHPunit

$ this- & gt; selectFrame (`` FRAME_NAME '');

Python

driver.switch_to.frame (`` FRAME_NAME '');

JavaScript

driver.switchTo () .frame (`` FRAME_NAME '');

Java

driver.switchTo () .frame (`` FRAME_NAME '');

Here, FRAME_NAME refers to Id, name,, and early.

Learn more about.

Challenges of testing Browser Extensions

Browser extensions are embedded add-ons, not veritable HTML files. Since the extension is out of scope, it is not possible to simulate user activeness such as chink and ringlet, inspect web elements, etc.

Normally websites can be easily tested by automatize user actions with. But in order to automate activeness on a browser extension, examiner have to identify where the extension ’ s pages are situate. Then, they would have to switch their scope in the web UI to interact with the extension pages as DOM elements.

The steps delineate above enables testers to avoid that process and interact with an extension like they do with a normal HTML webpage.

Thus, one can test a Chrome Selenium plugin withautomated Selenium testing. It is an simple process that just requires a few minutes of extra effort. In return, testing an important aspect of the website user experience get a simple task.

Why Use BrowserStack to Test Chrome Extensions?

Using tools like BrowserStack to test Chrome extension is a outstanding option. Here & # 8217; s why

  • Test on Real Devices: Extensions can behave otherwise across operating scheme or browser versions. With the help of BrowserStack ’ s you run your tests on various real devices, browser versions and OSs to ensure consistent behavior.
  • : Test the consistency of your Chrome extension & # 8217; s UI and functions across assorted browser versions.
  • CI/CD Integration: Integrate BrowserStack seamlessly with like, etc. to automatically run extension trial when the code is modified.
  • Effective Debugging: WIth features like screenshots, video recording of tests, console logs etc. you can debug and resolve issues easily.

Talk to an Expert

Conclusion

To summarize, for quiz Chrome propagation with Selenium, you will have to configure the browser to found with the extension enabled. This allows you to automate and verify its functionality across various scenario. This helps ensure your extension behaves as intended in.

Useful Resources for Automation Testing in Selenium

Methods, Classes, and Commands

Configuration

XPath

Locators and Selectors

Waits in Selenium

Frameworks in Selenium

Miscellaneous

Best Practices, Tips and Tricks

Design Patterns in Selenium: Page Object Model and Page Factory

Action Class

TestNG and Selenium

JUnit and Selenium

Use Cases

Types of Testing with Selenium

Tags
24,000+ Views

# Ask-and-Contributeabout this theme with our Discord community.

Related Guides

Automate This With SUSA

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.

Try SUSA Free

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free