Requestly is a powerful browser extension that allows developers and QAs to intercept and modify HTTP requests. It offers features like:
-
HTTP header modifications
-
URL redirects
-
Request and response body overrides
-
Injecting custom CSS and JavaScript
In this guide, we’ll show you how to use Requestly in an end-to-end (E2E) web testing framework.
What You Can Do with Requestly in Automation For now
There are 2 main ways to use Requestly in an automation environment:
We also offer an NPM package, @requestly/rq-automation, to make this easier.
Learn more →
-
Header Modifications — quick, one-off rules (no API key required)
-
Import Rules via API Key — for predefined rules managed from your Requestly account
Header Modifications
If you only need simple header overrides (without API key), like adding or removing request/response headers, refer to this page:
Modify HTTP Headers →
Import Rules via API Key
Configure Rules in a Team Workspace and Get API Key
Start by creating the rules you want to use in a new team workspace. Once the rules are set up, request an API key for the workspace by filling out this form. The rules in this workspace will be automatically fetched and applied during the end-to-end (E2E) testing in the browser instance.
Install Chrome for Testing
Download Chrome for Testing, the automation-friendly version of Chrome.
Why Chrome for Testing?
Starting with Chrome 137, official Chrome builds no longer support the --load-extension
flag due to security concerns. There commit →
To load extensions in automation tools (Selenium, Playwright, Puppeteer, etc.), you must use Chrome for Testing or Chromium.
Regular Chrome will block extension loading via automation. Use Chrome for Testing to avoid breakages and ensure compatibility.
Install the Automation Tool of Your Choice
npm install selenium-webdriver
Download the Requestly CRX Extension
If you're using our NPM package, you don’t need to download it. Simply call the function getExtension()
.
Download the CRX file of the Requestly Extension.
Configure the Browser with the Extension
Use your automation tool’s configuration options to:
-
Set the path to Chrome for Testing binary
-
Add the Requestly CRX extension
For JavaScript, use our NPM package @requestly/rq-automation
.
Learn more →
For Javascript ( Node.js )
const { Builder } = require("selenium-webdriver");
const chrome = require("selenium-webdriver/chrome");
const path = require("path");
const extensionPath = path.resolve(__dirname, 'requestly.crx'); // unpacked CRX folder
// IF Using Our NPM Package @requestly/rq-automation
const { getExtension } = require("@requestly/rq-automation");
const extensionPath = getExtension("crx");
// -----
const options = new chrome.Options();
options.setChromeBinaryPath("/Path/to/chrome-for-testing");
options.addExtensions(extensionPath);
const driver = await new Builder()
.forBrowser("chrome")
.setChromeOptions(options)
.build();
// Now use driver.get() to navigate as needed...
For Python
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.binary_location = "/Path/to/chrome-for-testing"
chrome_options.add_extension("/path/to/requestly.crx")
driver = webdriver.Chrome(options=chrome_options)
# driver.get(...) to open pages
For Java
ChromeOptions options = new ChromeOptions();
options.setBinary("/Path/to/chrome-for-testing");
options.addExtensions(new File("/path/to/requestly.crx"));
WebDriver driver = new ChromeDriver(options);
// driver.get(...) to open pages
(Optional) Close Extension Welcome Page
When Chrome installs the Requestly extension, it may open a "welcome" (post-install) tab that interrupts automation. You can close this tab programmatically:
// give Chrome a moment for any stray tabs
await driver.sleep(500);
// close any “welcome” tab if still present
const handles = await driver.getAllWindowHandles();
const mainHandle = handles[0];
for (const handle of handles.slice(1)) {
await driver.switchTo().window(handle);
await driver.close();
}
await driver.switchTo().window(mainHandle);
Import Rules from Requestly
Visit the following URL in your automated browser to import all active rules from your account:
https://app.requestly.io/automation?apiKey=<YOUR_API_KEY>