Selenium WebDriver


modheader/modheader_selenium is our repo for using ModHeader in WebDriver. We created special builds for ModHeader that expose some URLs as APIs to manipulate ModHeader. These APIs are not available in the regular ModHeader. With these builds, you can setup WebDriver to configure ModHeader programmatically.


To use this in NodeJS for Chrome, install the chrome-modheader package:
npm install chrome-modheader
To use this in NodeJS for Firefox, install the firefox-modheader package:
npm install firefox-modheader
For other programming languages, you can download the prepackaged extensions below and load them into WebDriver as needed.


Take a look at the examples directory for more detailed examples
Selenium Webdriver with Chrome:
const { getExtension, getAddHeaderUrl } = require('chrome-modheader');
const options = new chrome.Options().addExtensions(getExtension());
const driver = await new Builder().forBrowser('chrome').setChromeOptions(options).build();
await driver.get(getAddHeaderUrl('HeaderName', 'HeaderValue'));
Selenium Webdriver with Firefox:
const { getExtension, getAddHeaderUrl } = require('firefox-modheader');
const options = new firefox.Options();
const driver = await new Builder().forBrowser('firefox').setFirefoxOptions(options).build();
await driver.get(getAddHeaderUrl('HeaderName', 'HeaderValue'));
Modify wdio.conf.js file
const chromeModheader = require('chrome-modheader');
const firefoxModheader = require('firefox-modheader');
exports.config = {
capabilities: [
browserName: 'chrome',
'goog:chromeOptions': {
extensions: [chromeModheader.getEncodedExtension()]
browserName: 'firefox'
services: [
['selenium-standalone', { logPath: 'logs', installArgs: { drivers }, args: { drivers } }],
extensions: [firefoxModheader.getExtension()]
before: function (capabilities, specs) {
browser.url(chromeModheader.getAddHeaderUrl('accept-encoding', ''));
Java Selenium
For Chrome
Path currentRelativePath = Paths.get("chrome-modheader/modheader.crx");
ChromeOptions options = new ChromeOptions();
options.addExtensions(new File(currentRelativePath.toAbsolutePath().toString()));
ChromeDriver driver = new ChromeDriver(options);
For Firefox
FirefoxDriver driver = new FirefoxDriver();
Python Selenium
For Chrome
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(options=options, service=Service(ChromeDriverManager().install()))
For Firefox
driver = webdriver.Firefox(service=Service(GeckoDriverManager().install()))


All APIs are URL-based. Please make sure to URL encode your name and value properly.
Note that the URLs only work when the extensions are properly loaded. Older versions of the extensions use and These will continue to work in the newer version.
If you are using npm, you can also use the getAddHeaderUrl(), getAddHeadersUrl() and getClearHeadersUrl() functions to craft these URLs. Be sure to do driver.get(), and be mindful that these will change the URL of the WebDriver.
Add request header:{name1}={value1}&{name2}={value2}&...
Node API equivalent:
function getAddHeaderUrl(name, value) {}
function getAddHeadersUrl({ name: value }) {}
Construct the URL above using getAddHeaderUrl('Test', '1') or getAddHeadersUrl({ Test: '1' })
Clear all modified request headers:
Node API equivalent:
function getClearHeadersUrl() {}
Load custom profile:{exported_profile_in_json}
exported_profile_in_json can be obtained from the regular ModHeader extension using ... -> Export Profile.
Node API equivalent:
function getLoadProfileUrl(exported_profile) {}


  • Does this work in headless mode?
    • Yes, but be sure to use --headless=chrome, not --headless.
  • Why am I getting can't be reached page?
    • Double checkt to see if you are --headless=chrome
    • Try adding a small delay (maybe 1-2 seconds) before navigating to
    • does not map to a real website. It is intercepted by the ModHeader selenium extension to redirect to the extension hosted URL. This allows us to provide a single URL for both Chrome and Firefox without depending on the exact extension ID. Furthermore, this means that the test data you use in your test won't be sent to any real server (i.e., they will not get logged!).
    • However, if ModHeader selenium extension is not installed correctly, or if it encountered issues at initialization time, this functionality will not work, and will point to nothing, resulting in an error page. If you see this, please do go to chrome://extensions, enable "Developer mode" (top right corner), then click on ModHeader's "background page" link. This should open up the "Console". Send the errors to [email protected] This will help us identify the root cause.