A campaign page has to work for every visitor it was built for, whichever browser they use and wherever they are. Playwright suits that kind of QA. One API, in Python or Node.js, drives Chromium, Firefox and WebKit, the engine behind Safari. Proxy support, including a username and password, is part of its launch and context options, so there are no extensions to build and no login pop-ups to work around.
This guide shows a team how to set a proxy for a whole browser, how to give each browser context its own market, and how to keep test runs lean and compliant.
A market-by-engine test matrix
Most teams end up testing a grid: each engine, in each market that matters. Playwright makes the grid practical because markets can differ per context inside one browser process.
| Engine | Represents | Typical check |
|---|---|---|
| Chromium | Chrome and Edge users | Layout, consent banner and tracking tags per market |
| Firefox | Firefox users | Forms, fonts and regional formats |
| WebKit | Safari on Mac and iPhone | Rendering differences on Apple devices |
Installation and a credentials check
Python:
pip install playwright
playwright installNode.js:
npm install playwright
npx playwright installThe second line of each pair downloads the browser builds. Your order's four values appear in the examples as HOST, PORT, USER and PASS. Confirm they work before adding browsers to the mix:
curl --proxy http://USER:PASS@HOST:PORT https://api.ipify.orgOne proxy for the whole browser
The quickest setup hands a proxy dictionary to launch(). Server, username and password are separate fields, so there is no login string to assemble:
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch(
headless=True,
proxy={
"server": "http://HOST:PORT",
"username": "USER",
"password": "PASS",
},
)
page = browser.new_page()
page.goto("https://api.ipify.org")
print(page.content())
browser.close()Playwright answers the proxy's request for credentials itself, and the page loads without a prompt. The Node.js version follows the same shape:
const { chromium } = require("playwright");
(async () => {
const browser = await chromium.launch({
headless: true,
proxy: {
server: "http://HOST:PORT",
username: "USER",
password: "PASS"
}
});
const page = await browser.newPage();
await page.goto("https://api.ipify.org");
console.log(await page.content());
await browser.close();
})();A different market in each context
Playwright's most useful proxy feature for QA is the per-context proxy. Each browser context is isolated, with its own cookies and storage, so one browser process can run the UK check, the German check and the French check side by side through different endpoints. In Python:
from playwright.sync_api import sync_playwright
endpoints = [
{"server": "http://HOST:PORT1", "username": "USER", "password": "PASS"},
{"server": "http://HOST:PORT2", "username": "USER", "password": "PASS"},
]
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
for ep in endpoints:
ctx = browser.new_context(proxy=ep)
page = ctx.new_page()
page.goto("https://api.ipify.org")
print(page.inner_text("body"))
ctx.close()
browser.close()With sticky endpoints, give each market its own entry in the list. With a single rotating gateway, every context can point at the same address and each session will still exit from a new IP.
SOCKS5: what the team should know
The server field takes the scheme as a prefix: http://HOST:PORT for HTTP and HTTPS traffic, or socks5://HOST:PORT for SOCKS5. Note that Playwright does not support a username and password with SOCKS5 proxies. For login-based orders, use the HTTP scheme, which carries HTTPS sites through a CONNECT tunnel; for SOCKS5, switch the order to IP-whitelist authentication in the dashboard.
Lighter runs for text-only checks
Proxy data is billed per gigabyte, and images, video and fonts make up a large part of most pages. When a test only reads text or checks links, Playwright's routing API can skip them:
page.route("**/*", lambda route: (
route.abort()
if route.request.resource_type in ["image", "media", "font"]
else route.continue_()
))Keep full loading for visual tests and screenshots, where those assets are exactly what you are checking.
Choosing the type for each check
For consumer-facing pages that must match what local households receive, use residential proxies or residential premium proxies. For mobile-first pages and carrier-specific content, choose mobile proxies. For staging environments, internal tools and permissive public sites, datacenter proxies keep test runs quick and inexpensive. Rates are listed on the pricing page, and the full catalogue shows every type in one place.
Verify before the suite grows
Make the first step of each context a visit to an IP endpoint, as in the examples above, and fail the run if the address is not the proxy's. Our proxy checker gives an independent result for the same credentials, and the My IP tool shows your direct address for comparison.
Compliance for automated testing
Automated browsers can overload a site when nobody is watching the pace. For any third-party site in your suite, read its robots.txt, follow its Terms of Service, wait between actions and collect only public information you are permitted to use. Do not use Playwright to get past authentication or anti-fraud measures, or to collect personal information without a lawful basis. Paced, well-behaved suites keep your test results and your proxy addresses dependable.