In this guide, we’ll walk through how to integrate Requestly into any browser-based automation framework (Selenium, Playwright, Puppeteer, etc.) to programmatically modify request and response headers.
Steps to Use Requestly for Header Modification in Automation
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
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 ( Node.js )
const { Builder } = require("selenium-webdriver");
const chrome = require("selenium-webdriver/chrome");
const path = require("path");
const options = new chrome.Options();
options.setChromeBinaryPath("/Path/to/chrome-for-testing");
options.addExtensions(path.resolve(__dirname, "requestly.crx"));
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
Perform Header Modifications Using Automation URLs
Once the browser is launched with Requestly, hit the following URLs to programmatically apply rules:
Add Request Header
https://app.requestly.io/automation/add-request-header?<headerName>=<headerValue>
To add multiple headers, simply append them using the &
symbol like this:
?header1=value1&header2=value2&header3=value3
Add Response Header
https://app.requestly.io/automation/add-response-header?<headerName>=<headerValue>
Remove Request Headers
https://app.requestly.io/automation/remove-request-header?<headerName>
To remove multiple headers, simply append them using the &
symbol like this:
?header1&header2&header3
Remove Response Headers
https://app.requestly.io/automation/remove-response-header?<headerName>
Test on a Live Site
To verify if the headers are successfully modified, open https://testheaders.com in the automated browser and inspect the headers shown.
You may need to trigger a button click to reveal headers on some pages.
Complete Working Example in Selenium ( Javascript )
Here’s a working example using Selenium, but this logic can be adapted easily to Playwright, Puppeteer, or others.
const { Builder, By, until } = require("selenium-webdriver");
const chrome = require("selenium-webdriver/chrome");
const path = require("path");
(async () => {
const options = new chrome.Options();
options.setChromeBinaryPath("/Path/to/chrome-for-testing");
options.addExtensions(path.resolve(__dirname, "requestly.crx"));
const driver = await new Builder()
.forBrowser("chrome")
.setChromeOptions(options)
.build();
try {
await driver.get("https://app.requestly.io/automation/add-request-header?x-testing=selenium");
await driver.wait(
until.elementTextContains(
driver.findElement(By.tagName("body")),
"Success"
),
1000
);
await driver.get("https://testheaders.com");
await driver.findElement(By.css("button")).click();
await driver.wait(
until.elementTextContains(
driver.findElement(By.tagName("body")),
"x-testing"
),
5000
);
console.log("Header added and verified!");
} catch (err) {
console.error("Error during automation:", err);
} finally {
await driver.quit();
}
})();