The Agile Way

The Agile Way

Share this post

The Agile Way
The Agile Way
Testing Locale-Aware Websites in Automated Test Scripts

Testing Locale-Aware Websites in Automated Test Scripts

A Simple and Practical Tip for Localisation Testing

Courtney Zhan's avatar
Courtney Zhan
Feb 08, 2025
∙ Paid
3

Share this post

The Agile Way
The Agile Way
Testing Locale-Aware Websites in Automated Test Scripts
1
Share

Some websites are locale-aware, meaning they display content based on the user’s region or language settings. Let me illustrate with an example website.

  1. Visit test server #2 on a machine configured with the Australia region (language: English).

2. Visit test server #1 on a machine configured with the China region (language: Simplified Chinese).

See my other article on setting your browser’s language.

A Typical Way to Make Automated E2E Test Scripts Work for All Locales.

This solution is NOT to use a locator referencing the text, e.g. :text, or placeholder attributes. Rather, using :id, :name attributes.

The following Selenium statements work better for Locale-aware sites:

driver.find_element(:name, "username").send_keys("John")
driver.find_element(:id, "password").send_keys("secret-password")
driver.find_element(:id, "sign-in-btn").click()

Playwright testers might find this is against its recommended style:

await page.getByLabel('User Name').fill('John');
await page.getByLabel('Password').fill('secret-password');
await page.getByRole('button', { name: 'Sign in' }).click();

For more, check out the article, Correcting Wrong ‘Playwright’s Advantage over Selenium” Part 9: “Playwright ARIA locator support”

Some readers might think, this might not be feasible as not all websites provide unique and meaningful IDs/Names. True, there is another way.

Tip: Use a Locale Flag in E2E Test Scripts

The Problem

Let me start with an example. I ran one automated test script on the Chinese-locale machine.

Screenshot of a failed spam-detection test case executed via TestWise IDE on the Chinese machine.

Please note the same test script passed on other machines, in the English locale.

The test failed on step “new_business_page.select_business_type('other')”. Why? the text option for the business-type dropdown is in Chinese: "其他", instead of “other”.

(TestWise kept the browser window open, after test execution completion, for inspection)

Therefore, the select-business-type step failed as the 'other' option was not there. Furthermore, there was no unique ID for that drop-down option.

(The UUID does not count, and should never be used E2E test script)

The Solution

There is a very simple yet effective solution, as is often the case in Ruby scripts.

Keep reading with a 7-day free trial

Subscribe to The Agile Way to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Zhimin Zhan
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share