Skip to content

← All integrations

Browser automation

A real browser still makes HTTP requests. Playwright and Puppeteer both take the proxy as launch or context configuration, with no extension required. Selenium needs one extra step, because its own proxy capabilities have no field for a password.

Playwright

Set the proxy per browser context rather than per browser, so different contexts in the same run can hold different proxy users or targeting.

javascript
import { chromium } from "playwright";

const browser = await chromium.launch();
const context = await browser.newContext({
  proxy: {
    server: "http://gate.avocadoproxies.com:8080",
    username: "USERNAME-cc-de",
    password: "PASSWORD",
  },
});

const page = await context.newPage();
await page.goto("https://example.com");
console.log(await page.title());
await browser.close();

Puppeteer

Puppeteer takes the host and port as a launch argument, then authenticates separately with page.authenticate. Call it before the first navigation, on every page you open.

javascript
import puppeteer from "puppeteer";

const browser = await puppeteer.launch({
  args: ["--proxy-server=gate.avocadoproxies.com:8080"],
});

const page = await browser.newPage();
await page.authenticate({ username: "USERNAME-cc-de", password: "PASSWORD" });
await page.goto("https://example.com");
console.log(await page.title());
await browser.close();

Selenium

Selenium’s Proxy capability takes a host and port, but no username or password, so there is no built-in way to answer the browser’s own auth prompt. The common workaround is a small unpacked extension that supplies the login and password automatically, loaded the same way you would load any other extension for the session:

  • Chrome: build a minimal manifest.json + background script that answers chrome.webRequest.onAuthRequired with your login and password, and load it with --load-extension (or Selenium’s add_extension).
  • Firefox: the equivalent is a signed or temporary add-on installed via webdriver.firefox.profile that does the same for browser.webRequest.onAuthRequired.
  • Either way, set --proxy-server / the Proxy capability to the host and port as usual, and let the extension carry the login and password.
Restricting a proxy user’s IP allowlist to your automation host does not remove the prompt: the browser still authenticates with Basic auth every time, and the allowlist is an additional check.

Sticky or rotating

One browser context (or one Selenium session) is usually one job, so give it a session id: USERNAME-sid-job42-ttl-30 holds the same exit address for every page that context opens, which matters for a login-then-click flow. Leave the id off and each new context may land on a different address.

See Sticky sessions for lifetimes. A lifetime is a ceiling, so a long automation run should tolerate a fresh address if the lifetime is reached mid-flow.
  • Test it. Run either script above and check the printed page title. Open Dashboard → Usage → Live and watch example.com land within a few seconds.
  • For anything else, see the troubleshooting page.
Browser automation · Avocado Proxies