September 7, 2018

Python - Using Chrome Extensions With Selenium WebDriver

When you launch a Chrome browser from Selenium, a fresh temporary profile is created for the browser session. This means that by default, Chrome extensions are not loaded. To use an extension during a Selenium test, you must install the extension each time you launch a new browser.

Example 1: Installing a packed extension

A packed extension comes in the form of a single .crx file.

You can install a packed extension like this:

Example 2: Installing an unpacked extension

An unpacked extension is a directory containing extension code.

You can install an unpacked extension like this:

examples tested with: chromium 68, chromedriver 2.41, selenium 3.14