Skip to main content

How to Emulate the Location, Time Zone and Locale

Intro​

Many pages change with where the user is and which language they speak: a store shows the nearest shops, a booking site shows times in the local time zone, and a bank shows prices like 1.234,50 € in Germany and €1,234.50 in the US.

The test machine has only one location, one time zone and one language. So how do we test the page as a user in Berlin, or in Tokyo, would see it?

A Solution​

Tell the browser what to report. The page reads the location, the time zone and the language from the browser, so the test can change them before it loads the page:

  • Location: the browser returns the given latitude and longitude when the page asks for the location. The page also needs the geolocation permission, or the browser asks the user first. The test grants it.
  • Time zone: dates show in the given time zone (e.g., Asia/Tokyo).
  • Locale: the browser reports the given language (e.g., de-DE), formats dates and numbers with it, and sends it to the server in the Accept-Language header.

Selenium does it with WebDriver BiDi: the emulation module changes what the browser reports, and the permissions module grants the permission. Selenide uses the same Selenium classes. Playwright sets them as options of the browser context, and WebdriverIO uses browser.emulate. Vibium can change the time zone, but it can't grant permissions or change the locale yet, so its examples show the time zone only.

Example​

The examples use two pages of the-internet:

  • Geolocation: the "Where am I?" button asks the browser for the location and shows the latitude and longitude. The test sets the location to Berlin (52.52, 13.405).
  • Locale & Time Zone: the server greets the user in the language of the Accept-Language header, and the page shows the language and the time zone of the browser, a date (2026-04-15 12:00 UTC) and a number formatted with them. The test sets the time zone to Asia/Tokyo and the locale to de-DE, so the date shows as Mittwoch, 15. April 2026 um 21:00, the number as 1.234.567,891, and the greeting as Hallo!.

Expected Behavior​

  • The browser starts
  • The first test grants the geolocation permission and sets the location to Berlin
  • It clicks "Where am I?", and the page shows the latitude and longitude of Berlin
  • The second test sets the time zone to Tokyo and the locale to German
  • The page greets the user in German, and shows the date and the number in German, at the time of Tokyo
  • The browser closes

Summary​

Changing the location, the time zone and the locale lets one machine test the page as users from anywhere see it. Set them before the page loads, since many pages read them only once.

Happy Testing!

Authors​

Diego Molina
Elemental Selenium maintainer