Skip to content


There is an enhanced L10N utility to support localized (L10N) test automation testing. It can load localized resources on the fly and verify texts if needed.

We recommend to use existing localized resources and don't generate them by automation team!


Localized resources should be located in src/main/resources/L10N folder. Each localized resource file has unique keys with translated values.

Verify that there is a must have file without any postfix like This file will be considered as a default localization.


Define parameters in

#Localization language

#Optionally you could operate browser locale as well by using

#Enables auto verification for elements, that are marked with @Localized (by default it's false)

#Encoding for a new localization (by default UTF-8)

Then declare page elements with @Localized annotation. For example:

@FindBy(id = "pt-createaccount")
private ExtendedWebElement createAccountElem;

@FindBy(id = "pt-anoncontribs")
private ExtendedWebElement contribElem;

@FindBy(xpath = "//nav[@id='p-navigation']/descendant::ul[@class='vector-menu-content-list']/*")
private List<ExtendedWebElement> pageLinks;

Add to the project resources that corresponds to @Localized elements:

#!The key from locale file should have Page name + name of variable that needs to be compared.
WikipediaLocalePage.createAccountElem=fiók létrehozása

#!Elements from List should have the same name of a variable + current element's number
WikipediaLocalePage.pageLinks2=Kiemelt szócikkek
WikipediaLocalePage.pageLinks3=Friss változtatások
WikipediaLocalePage.pageLinks4=Lap találomra

For elements that are operated in test and marked with @Localized annotation Carina will automatically compare text from the page with text from your file. Every mismatch will be collected in L10N class.

To assert collected assertions use L10N.assertAll() method.

If you want to do it manually use L10N.getText(key) to get expected translations from resources:

String welcomeText = wikipediaLocalePage.getWelcomeText();
String expectedWelcomeText = L10N.getText("welcomeText");
Assert.assertEquals(welcomeText, expectedWelcomeText.trim(), "Wikipedia welcome text was not the expected.");

Resources generation

To generate resources with Carina, you need to enable localization_testing parameter.For elements that are need localization, you need to mark them with @Localized and operate with them. In test call L10N.flush() to create new locale file in your project directory. Example:

public void testAddNewLanguages() {
    WikipediaHomePage wikipediaHomePage = new WikipediaHomePage(getDriver());;

    WikipediaLocalePage wikipediaLocalePage = wikipediaHomePage.goToWikipediaLocalePage(getDriver());




    L10N.assertAll(); // not necessary for resources generation

Finding elements with a help of locales

Declare elements with L10N prefix where needed. Use key after the ":" sign in @FindBy annotations which will be replaced by actual localized translations.

@FindBy(xpath = "//*[text()='{L10N:welcomeText}'")
private ExtendedWebElement welcomeText;

@FindBy(linkText = "{L10N:discussionElem}")
private ExtendedWebElement discussionBtn;

At runtime actual translations will be used to locate elements

xpath = "//*[text()='{L10N:HomePage.welcomeText}'"
# actual value at run-time:
xpath = "//*[text()='Willkommen bei Wikipedia'"

Creation of multi-language tests

If one or a group of tests checks several language versions of the site, then you need to do the following: 1. [Optional] if you need to change the language version of the site, you can overwrite the locale parameter:

# overwrites locale value with de_DE for this test only
R.CONFIG.put("locale", "de_DE", true);
  1. Call the setLocale function and pass the locale to it:
# overwrites the default locale in the file to 'de_DE'
  1. Call the load function to download the localized resource of the current locale:
  1. When you need to get a list of locale errors, call assertAll: