Reproducible Geo-Testing with Playwright: How to Debug Location-Specific Web Behavior
Our guides are based on hands-on testing and verified sources. Each article is reviewed for accuracy and updated regularly to ensure current, reliable information.Read our editorial policy.
A web application can work perfectly in your development environment and still fail for users in another country, state, or city. The symptom might be a different price, a missing product, an unexpected redirect, a localized search result, or a payment method that never appears.
Seeing that the behavior changes is the easy part. The hard part is identifying which environmental variable caused it. IP location is only one candidate: browser locale, timezone, cookies, account settings, CDN routing, cached content, and feature flags can all change what a user receives.
This tutorial shows how to build a geo-testing workflow with Playwright and a geo-targeted proxy, where each of those variables is controlled independently and every result can be reproduced by another engineer.
What we are actually testing
Suppose a customer reports: “The checkout page shows a different offer when I access it from Germany.” There are several possible explanations:
- The application reads the visitor’s IP location.
- The browser sends a German locale.
- The account is registered in Germany.
- A cookie holds a previous regional preference.
- A CDN edge is serving different cached content.
- A country-specific feature flag is active.
- A third-party service responds differently by region.
Change all of these at once and you may reproduce the bug without learning its cause. Treat each one as a separate test input instead.
Step 1: Set up a clean Playwright project
Install Playwright and its browsers:
npm install -D @playwright/test dotenv
npx playwright installKeep proxy credentials out of your source code. Put them in a .env file and add that file to .gitignore:
PROXY_SERVER=http://proxy-host:port
PROXY_USER=username
PROXY_PASS=password
TARGET_URL=https://example.comPlaywright does not read .env files on its own, so we load it with dotenv in the config below. The examples in this article use TypeScript, Playwright’s default.
Step 2: Configure the proxy separately from browser locale
Playwright supports HTTP(S) and SOCKS5 proxies natively. A basic playwright.config.ts looks like this:
import 'dotenv/config';
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
proxy: {
server: process.env.PROXY_SERVER!,
username: process.env.PROXY_USER,
password: process.env.PROXY_PASS,
},
locale: process.env.TEST_LOCALE || 'en-US',
timezoneId: process.env.TEST_TIMEZONE || 'America/New_York',
trace: 'retain-on-failure',
},
});These three settings control different things. The proxy sets the network path and exit IP. locale sets browser signals such as navigator.language, the Accept-Language header, and number and date formatting. timezoneId sets the timezone the page sees.
They all relate to geography, but they are not the same thing. A German IP with en-US and America/New_York tells you something very different from a test where all three point to Germany.
Step 3: Confirm the environment before testing the application
Before reproducing the bug, record what Playwright is actually presenting to the site, including the real exit IP:
import { test } from '@playwright/test';
test('record test environment', async ({ page }) => {
// Ask an IP-echo service which address the proxy is exiting from
await page.goto('https://api.ipify.org?format=json');
const exitIp = JSON.parse(await page.locator('body').innerText());
const browserEnv = await page.evaluate(() => ({
language: navigator.language,
languages: navigator.languages,
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
userAgent: navigator.userAgent,
}));
console.log({ ...exitIp, ...browserEnv });
});Then look up that IP’s country, region, and city with a geolocation service you trust. Never assume that requesting a location means you are exiting from it.
Save this record with every test result: exit IP, country, region, city (when relevant), browser locale, timezone, browser version, and timestamp. It is what lets another engineer reproduce your result later.
Step 4: Capture the network traffic that matters
A screenshot proves two pages look different, but it rarely explains why. Network data usually does:
import { test } from '@playwright/test';
test('capture important responses', async ({ page }) => {
page.on('response', response => {
const url = response.url();
if (/\/api\/|\/pricing|\/checkout/.test(url)) {
console.log({ url, status: response.status() });
}
});
await page.goto(process.env.TARGET_URL!, { waitUntil: 'load' });
});For location-sensitive applications, watch pricing and localization APIs, inventory endpoints, redirects, feature-flag services, checkout and authentication calls, CDN headers, cookies, and currency data. Two pages can look identical while an API response carries a different region, price, currency, experiment ID, or availability flag.
Step 5: Keep stateful user journeys on one IP
Not every geo-test should rotate to a new IP for each request. Consider this flow:
- Open a product page.
- Add an item to the cart.
- Begin checkout.
- Load a payment method.
- Confirm the final price.
These steps form one user journey. If the IP changes in the middle, the test itself can create behavior a real user would never see. For multi-step flows, a sticky session that keeps one exit IP is the right model. Rotation suits independent samples, such as checking a public search result across many IPs.
The rule is simple: rotate between independent observations; keep one IP within a stateful journey.
When choosing a proxy layer, check that it offers both location targeting and session control. For example, ColdProxy supports country, state, and city targeting on its Residential IPv4 plans, with both rotating and sticky sessions, so you can match the network behavior to each test.
Step 6: Change one variable at a time
A diagnostic matrix keeps results easy to read:
| Test | Exit location | Locale | Timezone | Cookies |
|---|---|---|---|---|
| Baseline | Local | en-US | Local | Clean |
| A | Germany | en-US | Local | Clean |
| B | Local | de-DE | Local | Clean |
| C | Local | en-US | Europe/Berlin | Clean |
| D | Germany | de-DE | Europe/Berlin | Clean |
| E | Germany | de-DE | Europe/Berlin | Existing |
If only Test A changes the behavior, exit location is the likely trigger. If Test B changes it without a new IP, look at locale. If only Test E reproduces the bug, stored state is part of the cause. That is far more useful than connecting through another country and noting that “something changed.”

Step 7: Use isolated browser contexts
Each Playwright browser context has its own cookies, storage, and settings, so you can run clean, isolated sessions without restarting the browser.
One catch: a context you create manually with browser.newContext() does not inherit the use options from your config. Pass the proxy explicitly:
import { test } from '@playwright/test';
test('German locale in a clean context', async ({ browser }) => {
const context = await browser.newContext({
proxy: {
server: process.env.PROXY_SERVER!,
username: process.env.PROXY_USER,
password: process.env.PROXY_PASS,
},
locale: 'de-DE',
timezoneId: 'Europe/Berlin',
});
const page = await context.newPage();
await page.goto(process.env.TARGET_URL!);
await context.close();
});If persistent state is part of what you are testing, save and restore it deliberately (Playwright’s storageState does this) rather than letting it carry over by accident.
Step 8: Keep evidence when a test fails
The trace: 'retain-on-failure' setting from Step 2 is especially useful for intermittent regional bugs. A trace preserves browser actions, network activity, DOM snapshots, screenshots, timing, and console output, but only for failed runs. A failed geo-test then comes with evidence, not just an assertion error. Open it with npx playwright show-trace.

Step 9: Test several exit IPs before blaming a region
One failing German IP does not prove Germany is affected. The cause could be a single ISP, IP range, CDN route, stale edge cache, an address with an unusual reputation, or a temporary routing problem.
Repeat the test through several exits in the same country. If multiple independent IPs produce the same response while another country does not, the evidence for truly location-dependent behavior is much stronger.
Step 10: Compare responses programmatically
Structured comparison scales better than screenshots. If the application returns pricing as JSON, capture it for each region. Start waiting for the response before you load the page, or you may miss it:
const pricingPromise = page.waitForResponse(response =>
response.url().includes('/api/pricing')
);
await page.goto(process.env.TARGET_URL!);
const pricing = await (await pricingPromise).json();
console.log(JSON.stringify(pricing, null, 2));Then diff fields such as currency, country, region, price, productAvailability, campaignId, experimentId, and redirectUrl across regions. This usually finds the root cause faster than comparing two pages by eye.
A practical debugging sequence
- Record the user’s environment.
- Reproduce the page without changing anything.
- Clear cookies and storage.
- Change only the exit location, and verify the actual exit IP.
- Capture the relevant network responses.
- Change locale, then timezone, one at a time.
- Test the combined environment.
- Repeat through several IPs in the same region.
- Save the trace and responses.
At the end, instead of “The page is different in Germany,” you can say: “The pricing API returns a different product configuration whenever the request comes from a German IP, regardless of locale or timezone.” That is a reproducible engineering finding.
Common mistakes
- Treating IP location as the whole environment. An IP does not change locale, timezone, cookies, or account settings. Control those explicitly.
- Rotating IPs mid-journey. Changing the exit IP during login or checkout can create artificial failures.
- Reusing dirty browser state. Old cookies and local storage make identical tests behave differently. Start from a fresh context.
- Trusting one result. One proxy exit is one observation, not a whole country.
- Comparing only screenshots. A different page shows the symptom; the network responses usually show the cause.
Final thoughts
Reliable geo-testing is not about appearing to be somewhere else. It is about making geography a controlled test variable, separate from locale, timezone, session state, and application state.
Playwright handles the browser side: isolation, network inspection, tracing, and environment emulation. A well-configured proxy layer supplies the network location. Together, they turn a vague report like “this only happens in another country” into a test case any engineer can run and verify.



Comments
Comments are provided by Disqus, which sets cookies and processes data under its own privacy policy.