Skip to content

How to Test Website Rendering Across Countries with Playwright

Pages often change with the visitor's country. This guide shows how to use Playwright with a proxy to verify your own localized pages, with matching locale settings, stable assertions and clear limits.

10 min readUpdated Nov 14, 2026By XPASS Editorial Team

How to Test Website Rendering Across Countries with Playwright

Many websites do not look the same to every visitor. The currency changes, the language changes, a cookie notice appears in one region and not another, a local payment method shows up, or a region-specific banner replaces the usual one. If you build or maintain such a site, you need to see it the way visitors in each country see it. Playwright is well suited to this, because it can run real browsers, control the locale and timezone, and send traffic through a Proxy per browser context.

This guide explains how to run cross-country rendering checks against your own site, or a site you have permission to test. It covers the setup, the signals a site may use to decide what to show, how to write assertions that do not break every week, and the limits you should keep in mind.

What decides what a visitor sees

Before writing a test, list the signals your site actually uses. A page can vary by:

Signal Where it comes from How you control it in a test
IP-based location The exit IP, matched to a geolocation database Proxy exit in the target country
Accept-Language Browser language preferences Context locale option
Timezone and date formats Browser timezone Context timezoneId option
Cookies and local storage Earlier visits, consent choices Fresh context, or explicit cookies
URL path or subdomain Redirects or language switchers Test the URL and the redirect
Device and viewport User agent and screen size Context viewport, device descriptors

The most common mistake in geo testing is changing only the IP and leaving everything else at the defaults of the CI machine. A site that reads Accept-Language first will happily show English to a German exit. Keep every signal aligned with the scenario you want to represent.

A basic Playwright setup with a proxy

Playwright accepts a proxy setting on the browser launch and on each context. A context is an isolated browser profile, so one context per country is the natural unit.

import { chromium } from 'playwright';

const regions = [
  { name: 'de', locale: 'de-DE', timezone: 'Europe/Berlin', server: process.env.PROXY_DE },
  { name: 'jp', locale: 'ja-JP', timezone: 'Asia/Tokyo', server: process.env.PROXY_JP },
];

const browser = await chromium.launch();

for (const r of regions) {
  const context = await browser.newContext({
    locale: r.locale,
    timezoneId: r.timezone,
    proxy: {
      server: r.server!,
      username: process.env.PROXY_USER,
      password: process.env.PROXY_PASS,
    },
  });
  const page = await context.newPage();
  await page.goto('https://www.example.com/');
  // assertions here
  await context.close();
}

await browser.close();

The example uses placeholder values and reads the credentials from environment variables, which is how they should be stored. Supply the real proxy details from your provider's documentation or plan page. MDN's article on proxy servers and tunneling is a good background read if you want to understand how HTTPS traffic travels through the proxy.

If your test runner is @playwright/test, put the region list in the project configuration so each region becomes a separate project, with its own use block holding locale, timezone and proxy. Reports then group the results per country automatically.

Verify the exit before asserting anything

A rendering test is only meaningful if the browser really came from the country you think it did. Add a pre-check at the start of each context:

  1. Open a small endpoint on a domain you control that returns the client IP or region as JSON.
  2. Compare it with the expected country.
  3. Fail the test early with a clear message if they differ.

Treat the geolocation result as approximate. Databases can disagree for specific addresses, and a mismatch is a signal to investigate rather than proof of a bug in your site. Recording the observed address in the test report makes later debugging much easier.

Write assertions that survive change

Rendering tests fail for dull reasons when they are too tightly bound to content. Use these habits:

  • Assert on structure and key facts, not exact copy. Check that the currency symbol is correct, that a language attribute is set (html[lang]), that the expected banner exists, or that a particular element is hidden.
  • Prefer roles and test IDs. getByRole and data-testid selectors survive redesigns better than long CSS paths.
  • Wait for conditions, not time. Use expect(locator).toBeVisible() and network-idle waits rather than fixed sleeps.
  • Keep screenshots for review, not for strict diffs. Pixel comparisons across countries often fail because of ads, dates or rotating content. If you use them, mask dynamic regions.
  • Test the redirect itself. Check the final URL after navigation and the status chain if the site routes visitors by country.

Status codes and redirect semantics follow RFC 9110, which is useful when you need to decide whether a 302 or a 301 is the correct behaviour for a locale redirect.

Region-dependent consent banners are one of the most frequent reasons to run geo tests. Treat them as part of the thing you are testing:

  • Run one scenario with a clean context to confirm the banner appears where it should and not where it should not.
  • Run another scenario in which the test accepts or rejects consent, and verify that the page behaves accordingly afterwards.
  • Do not carry cookies from one country to another. Create a new context for each, or clear storage explicitly.

If your site stores the chosen region in a cookie, add a test that sets the cookie to a different country than the IP and confirms which of the two wins. That is a real-world situation for travellers and for users who use a VPN.

Organise the matrix

Testing every page in every country multiplies quickly. Build a matrix with intent:

  1. Pick the pages where location really matters: home, product listing, product detail, cart, checkout, legal notices and pricing.
  2. Pick the countries your business serves, plus one or two controls such as a country with no special handling.
  3. Run the full matrix on a schedule, and a smaller smoke set on each change.
  4. Keep the matrix in data (a JSON or YAML file), not in code, so product owners can review it.

When the matrix grows, apply the limits described in the guide on building a bounded proxy rotation strategy: fix the number of exits, cap the request rate to your own hosts and avoid hidden retries. For wiring the same tests into a pipeline, including secrets and timeouts, see setting up a proxy for integration tests in CI. If your main concern is language and price differences specifically, the companion article on checking pages with different language and price goes deeper into that comparison.

Performance and timeouts

A proxy adds latency, and a full browser loads many resources. Keep the following in mind:

  • Increase navigation and action timeouts for geo projects, but keep a hard cap on the test duration.
  • Block resources you do not need, such as large video files, if the test does not depend on them. Be careful not to block what the site needs to render.
  • Reuse a browser between contexts, but not a context between countries.
  • Limit parallel workers so you do not exceed the concurrent connection allowance of your plan.
  • Retry at most once for navigation errors, and never for assertion failures.

Limits and what to watch for

  • Only test what you are allowed to test. Respect the site's terms, its robots rules (RFC 9309) and local law. Geo testing is for verifying your own experience.
  • Do not use it to get around restrictions. If a site blocks a region on purpose, a rendering test is not a way to bypass that decision.
  • An IP is not a person. Real visitors have their own devices, extensions and network conditions that a test cannot reproduce fully.
  • Third-party scripts vary. Ads, analytics and consent platforms may behave differently on each run. Stub or ignore them in assertions where possible.
  • Geolocation databases disagree. A country label is an estimate; verify with a pre-check.
  • Do not store secrets in traces. Playwright traces and HAR files can include request headers. Scrub or restrict them before sharing.

A short checklist

  1. List the signals your site uses for localization.
  2. Create one browser context per country with locale, timezone and proxy.
  3. Run a pre-check that confirms the exit region.
  4. Assert on stable structure and key facts, with explicit waits.
  5. Keep contexts, cookies and storage separate between countries.
  6. Store reports, screenshots and traces securely, with short retention.
  7. Review the matrix and the logs regularly.

A worked example: currency and banner by country

Suppose your store shows prices in euros for Germany, yen for Japan, and shows a cookie consent banner only for visitors in Germany. A compact test plan for the product page might be:

  1. For Germany: open the product page in a context with de-DE, the Berlin timezone and a German exit. Assert that the price element contains the euro symbol, that html[lang] starts with de, and that the consent banner is visible.
  2. For Japan: open the same page with ja-JP, the Tokyo timezone and a Japanese exit. Assert that the price element contains the yen symbol, that html[lang] starts with ja, and that the consent banner is not present.
  3. For a control country: open the page with no special handling and assert that the default currency and language are used.
  4. For a mismatch case: use a German exit with ja-JP as the browser locale and assert which signal your site is meant to prefer. Whatever the answer is, write it down as a test so future changes cannot alter it silently.

Notice that none of these assertions depend on the exact wording of the page. If the marketing team rewrites a headline, the tests still pass. If someone breaks the currency logic or the banner condition, they fail immediately, with a report that states the country, the observed exit and the failing element.

Reading failures

When a cross-country test fails, work through the same order each time. First look at the pre-check: did the exit match the expected region? If not, the failure belongs to the route, not to your site. Second, look at the browser locale and timezone recorded in the report. Third, open the trace for the failing step and see which request returned the unexpected content. Only then conclude that the site's behaviour is wrong. Following a fixed order keeps the team from chasing bugs that were really network issues, and from dismissing real regressions as flakiness.

Summary

Cross-country rendering tests with Playwright work best when you align every signal a site can use: the exit IP, the language header, the timezone and the stored state. Use one context per country, verify the exit before asserting, and write assertions on structure and key facts rather than pixels of live content. Keep the matrix small and intentional, respect timeouts and concurrency limits, and use the approach only on sites you own or have permission to test. To see what proxy options are available for this kind of work, visit the Proxy page.

Frequently asked questions

How do I make Playwright use a proxy?

Pass a proxy option with the server address and, if needed, a user name and password, either when launching the browser or when creating a browser context. Using one context per country keeps each region's cookies and storage separate.

Is the proxy enough to make a page behave like a local visitor?

Not always. Sites may also read the Accept-Language header, the browser locale, the timezone and saved cookies. Set locale and timezone in the context so these signals match the country you are testing, and clear state between runs.

How do I keep rendering tests from being flaky?

Assert on stable elements rather than pixels of live content, wait for explicit conditions instead of fixed sleeps, pin one exit per context, and keep timeouts generous enough for the extra proxy hop.

Can I use this to check any website?

Use it on sites you own or are allowed to test, and follow their terms and local law. Geo testing is meant to verify your own localized experience, not to work around restrictions on someone else's site.

About the author

Bob Kanokphon Thongdee, founder of XPASS VPN

Bob Kanokphon Thongdee

  • Founder of XPASS VPN
  • Co-founder of eSIMonline.asia
  • More than 7 years in online marketing
  • Founder of Cojourney Visa and Cojourney Travel

Need a proxy for this?

XPASS Proxy sells residential proxy traffic by the gigabyte, with the price shown before you pay.

See proxy plans

Keep reading

Proxy Guides

How to Set Up a Proxy for Integration Tests in CI

Some integration tests need to run from a specific country or network. This guide shows how to wire a proxy into CI safely, with secrets, scoping, timeouts and reports you can trust.

9 min read

Proxy Guides

How to Use a Proxy to Check Pages with Different Languages and Prices

When a page shows another language or price depending on the visitor's country, you need a repeatable way to compare. This guide covers setup, a comparison sheet and the limits of lawful checking.

9 min read

Proxy Guides

How to Build a Bounded Proxy Rotation Strategy

Rotation is easy to start and hard to control. This guide shows how to set limits on pool size, requests per IP and retries so a lawful workload stays predictable and easy to debug.

9 min read