npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@requestly/rq-automation

v1.0.0

Published

Package for using Requestly in automation testing frameworks like Selenium, Playwright, and Puppeteer.

Readme

Requestly For Automation

A npm package for integrating Requestly with automation testing frameworks like Selenium, Playwright, and Puppeteer. This package allows you to modify network requests during automated testing by leveraging Requestly's browser extension capabilities. You can modify headers, user agents, and import your Requestly rules for a seamless testing experience.

Installation

npm install @requestly/rq-automation

Requirements

  • Node.js >= v18.20.8
  • A peer dependency for your chosen framework:
    • selenium-webdriver
    • playwright
    • puppeteer

Core Concept

The library works by generating special URLs. When your automated browser session navigates to one of these URLs, the Requestly extension intercepts it and configures the required rules. For example, to add a request header, you navigate to a URL generated by addRequestHeaderUrl().

API Reference

Here are the core functions provided by the package:

  • getExtension(type): Gets the path to the Requestly extension. type can be 'crx', 'xpi', or 'unpacked'.
  • closeWelcomePage(driver): Closes the Requestly welcome page that opens on the first run.

Request Headers

  • addRequestHeaderUrl(name, value): Adds a single request header.
  • addRequestHeadersUrl(headers): Adds multiple request headers from an object.
  • removeRequestHeaderUrl(name): Removes a single request header.
  • removeRequestHeadersUrl(headerNames): Removes multiple request headers from an array of names.

Response Headers

  • addResponseHeaderUrl(name, value): Adds a single response header.
  • addResponseHeadersUrl(headers): Adds multiple response headers from an object.
  • removeResponseHeaderUrl(name): Removes a single response header.
  • removeResponseHeadersUrl(headerNames): Removes multiple response headers from an array of names.

Importing Rules

  • importRules(apiKey): Import all rules from your Requestly account using API key.

Usage with Selenium WebDriver

Setup

const { Builder } = require("selenium-webdriver");
const chrome = require("selenium-webdriver/chrome");
const { getExtension } = require("@requestly/rq-automation");

async function setupDriver() {
  const options = new chrome.Options();

  // Load Requestly extension
  const extensionPath = getExtension("unpacked");
  options.addArguments(`--load-extension=${extensionPath}`);
  options.addArguments(`--disable-extensions-except=${extensionPath}`);

  const driver = await new Builder()
    .forBrowser("chrome")
    .setChromeOptions(options)
    .build();

  return driver;
}

Examples

const {
  addRequestHeaderUrl,
  addRequestHeadersUrl,
  removeRequestHeaderUrl,
  removeRequestHeadersUrl,
  addResponseHeaderUrl,
  addResponseHeadersUrl,
  removeResponseHeaderUrl,
  removeResponseHeadersUrl,
  importRules,
  closeWelcomePage,
} = require("@requestly/rq-automation");

async function seleniumExample() {
  const driver = await setupDriver();
  await closeWelcomePage(driver);

  // Add a single request header
  await driver.get(addRequestHeaderUrl("X-Custom-Header", "MyValue"));

  // Add multiple request headers
  await driver.get(
    addRequestHeadersUrl({
      Authorization: "Bearer token123",
      "X-Another-Header": "AnotherValue",
    })
  );

  // Remove a request header
  await driver.get(removeRequestHeaderUrl("X-Another-Header"));

  // Remove multiple request headers
  await driver.get(
    removeRequestHeadersUrl(["Authorization", "X-Custom-Header"])
  );

  // Add a response header
  await driver.get(addResponseHeaderUrl("Access-Control-Allow-Origin", "*"));

  // Add multiple response headers
  await driver.get(
    addResponseHeadersUrl({
      "X-Response-Header": "ResponseValue",
      "X-Another-Response-Header": "AnotherResponseValue",
    })
  );

  // Remove a response header
  await driver.get(removeResponseHeaderUrl("X-Another-Response-Header"));

  // Remove multiple response headers
  await driver.get(
    removeResponseHeadersUrl(["X-Response-Header", "X-Another-Response-Header"])
  );

  // Import a shared list of rules
  await driver.get(importRules("YOUR_API_KEY"));

  // Your test code here
  await driver.get("https://example.com");

  await driver.quit();
}

seleniumExample();

Usage with Playwright

Setup

const { chromium } = require("playwright");
const { getExtension } = require("@requestly/rq-automation");
const path = require("path");

async function playwrightExample() {
  const extensionPath = getExtension("unpacked");
  const userDataDir = path.join(__dirname, "user-data");

  const browser = await chromium.launchPersistentContext(userDataDir, {
    headless: false,
    args: [
      `--load-extension=${extensionPath}`,
      `--disable-extensions-except=${extensionPath}`,
    ],
  });

  const page = await browser.newPage();

  // ... see examples below

  await browser.close();
}

Examples

const { chromium } = require("playwright");
const { getExtension } = require("@requestly/rq-automation");
const path = require("path");
const {
  addRequestHeaderUrl,
  // ... import other functions
  importRules,
  closeWelcomePage,
} = require("@requestly/rq-automation");

async function playwrightExample() {
  const extensionPath = getExtension("unpacked");
  const userDataDir = path.join(__dirname, "user-data");

  const browser = await chromium.launchPersistentContext(userDataDir, {
    headless: false,
    args: [
      `--load-extension=${extensionPath}`,
      `--disable-extensions-except=${extensionPath}`,
    ],
  });
  await closeWelcomePage(browser);

  const page = await browser.newPage();

  // Add a request header
  await page.goto(addRequestHeaderUrl("X-Request-By", "Puppeteer"));

  // Import a shared list of rules
  await page.goto(importRules("YOUR_API_KEY"));

  // Navigate to your application
  await page.goto("https://example.com");
  await browser.close();
}

playwrightExample();

Usage with Puppeteer

Setup

const puppeteer = require("puppeteer");
const { getExtension } = require("@requestly/rq-automation");

async function puppeteerExample() {
  const extensionPath = getExtension("unpacked");

  const browser = await puppeteer.launch({
    headless: false,
    args: [
      `--load-extension=${extensionPath}`,
      `--disable-extensions-except=${extensionPath}`,
    ],
  });

  const page = await browser.newPage();

  // ... see examples below

  await browser.close();
}

Examples

const puppeteer = require("puppeteer");
const { getExtension } = require("@requestly/rq-automation");
const {
  addRequestHeaderUrl,
  // ... import other functions
  importRules,
  closeWelcomePage,
} = require("@requestly/rq-automation");

async function puppeteerExample() {
  const extensionPath = getExtension("unpacked");

  const browser = await puppeteer.launch({
    headless: false,
    args: [
      `--load-extension=${extensionPath}`,
      `--disable-extensions-except=${extensionPath}`,
    ],
  });
  await closeWelcomePage(browser);

  const page = await browser.newPage();
  await page.goto(addRequestHeaderUrl("X-Request-By", "Puppeteer"));

  // Import a shared list of rules
  await page.goto(importRules("YOUR_API_KEY"));

  // Navigate to your application
  await page.goto("https://example.com");

  await browser.close();
}
puppeteerExample();

Support

Keywords

requestly selenium playwright puppeteer webdriver chrome modify headers request headers response headers redirect delay throttle automation testing