Multi-lingual Test cases – Recommended!

Multi-lingual Test cases – Recommended!

Multi-lingual Test cases – Recommended!

It is very obvious, that by default or initially we automate test cases in English. But let not that fact be hidden that we release our projects/products in multiple countries wherein English is not a native language. So we have to keep in mind the native languages of different countries as to provide easy accessibility.

When QA automates the test cases for the products, it is essential to run them in different locals as well. Therefore if initially if we start creating the scripts without considering to run them on different languages, ultimately as a result the scripts will not work on all the locals as it will surely fail at some stages.

Thereby, I figured out a solution and I recommend it to you in the below steps:

1)       When you start automating testcases in English, store all the element locators that you would require in automation

2)      Start optimizing all the locators like below:

a)      Try to keep all the locators very small

b)      Track all the locators by their ids not their labels, link texts, etc as these will be converting into the selected language so pick the ids only

Let us consider an example:

When you go to Java page, you get the below options:

>>What is Java? >>Do I have Java? >>Need Help?

[Normal locator people uses: link=What is Java?]

Right click on >>What is Java>>Inspect Element

You will be directed to the below screen as shown below:

image 1

Create locator like: //div/p/span[1]/a it will work in all the languages

Below is the code to create for initializing Firefox webdriver in java into different locals:

private WebDriver createFirefoxDriver(Locale locale){

    FirefoxProfile profile = new FirefoxProfile();

    profile.setPreference(“intl.accept_languages”, formatLocale(locale));

    return new FirefoxDriver(profile);


  private String formatLocale(Locale locale) {

    return locale.getCountry().length() == 0

      ? locale.getLanguage()

      : locale.getLanguage() + “-” + locale.getCountry().toLowerCase();


Suppose, initially we start automating the test cases in Selenium with English language. But going forward, if you want to run your scripts in six or more different languages, this will be an easy way that will reduce your maintenance in future as you are already optimizing your locators in a way that will not fail in any of the locals.

Go ahead.. Try it!


Get A Free Quote