Custom locale or timezone
Mobitru supports a playwright browser session’s custom locale or timezone if it’s necessary to override the default values – en:en
and GMT+0
.
These features are available for all browsers.
Enable in tests
To start using the custom locale or timezone, it’s necessary to add the env
parameter(s) to a WebSocket endpoint.
The parameter(s) should contain appropriate item(s) with timezone or locale identifiers:
- Timezone: ‘TZ’ as keyword and appropriate identifier as value, for example
TZ=Europe/Istanbul
- Locale: ‘LC_ALL’ as keyword and appropriate identifier as value, for example
LC_ALL=de_AT.UTF-8
Important note: the WebSocket endpoint should be encoded to avoid issues with processing of the parameters.
Below you can find an example for different programming languages:
const playwright = require('playwright-core');
const mobitruHost = "browserhub-us.mobitru.com";
const mobitruTeamCode = "<TEAM_CODE>";
const mobitruAccessToken = "mobitru_ak...";
const pwVersion = "1.55.0";
const mobitruLandingUrl = 'https://mobitru.com/';
const browserName = 'chrome';
test.describe(`Demo test`, () => {
....
test.beforeAll(async ({}, testInfo) => {
const wsEndpoint = `wss://${mobitruTeamCode}:${mobitruAccessToken}@${mobitruHost}/playwright/${browserName}/playwright-${pwVersion}?env=LANG%3Dde_AT.UTF-8&env=LC_ALL%3Dde_AT.UTF-8&env=LANGUAGE%3Dat:de`;
....
});
....
private static final String PROJECT_NAME = "<TEAM_CODE>";
private static final String API_KEY = "mobitru_ak_...";
private static final String BROWSER_HUB = "browserhub-us.mobitru.com";
private static final String BROWSER_NAME = "chrome";
private static final String PW_VERSION = "1.54.0";
@Test
public void demoTest() {
String wsEndpoint = String.format("wss://%s:%s@%s/playwright/%s/playwright-%s?env=LANG%%3Dde_AT.UTF-8&env=LC_ALL%%3Dde_AT.UTF-8&env=LANGUAGE%%3Dat:de",
PROJECT_NAME, API_KEY, BROWSER_HUB, BROWSER_NAME, PW_VERSION);
....
}
import pytest
from playwright.sync_api import sync_playwright, Page, expect
BILLING_UNIT = '<TEAM_CODE>'
ACCESS_TOKEN = 'mobitru_ak_...'
MOBITRU_HOST = 'browserhub-us.mobitru.com'
BROWSER_NAME = 'chrome'
PW_VERSION = '1.55.0'
@pytest.fixture(scope="function")
def mobitru_page(request):
with sync_playwright() as playwright:
chromium = playwright.chromium
ws_endpoint = f"wss://{BILLING_UNIT}:{ACCESS_TOKEN}@{MOBITRU_HOST}/playwright/{BROWSER_NAME}/playwright-{PW_VERSION}?env=LANG%3Dde_AT.UTF-8&env=LC_ALL%3Dde_AT.UTF-8&env=LANGUAGE%3Dat:de"
....
private const string PROJECT_NAME = "<TEAM_CODE>";
private const string API_KEY = "mobitru_ak_....";
private const string BROWSER_HUB = "browserhub-us.mobitru.com";
private const string BROWSER_NAME = "chrome";
private const string PW_VERSION = "1.55.0";
[Test]
public void DemoTest()
{
string wsEndpoint = $"wss://{PROJECT_NAME}:{API_KEY}@{BROWSER_HUB}/playwright/{BROWSER_NAME}/playwright-{PW_VERSION}?env=LANG%3Dde_AT.UTF-8&env=LC_ALL%3Dde_AT.UTF-8&env=LANGUAGE%3Dat:de";
....
}