Please note that Sahi's development and support teams do not actively monitor this. This is more a community forum. If you are a Sahi Pro user looking for commercial support, please email support @ with your query.

Multi Language Support

Pratik Anand ShahPratik Anand Shah Moderators
edited August 2017 in Sahi Pro
Yesterday, few of my friends and I were having a coffee and one of my friends started complaining about his work. He works for a web application development company where the application is used across the globe with different languages. He was given the task to test the application on all available languages. He had to deal with many languages and they can add any language at any given time. He recorded the script in one language and the same won't work on any other language as the string will not be the same.

My another friend, who also had faced the same issue jumped into the discussion, saying we have created automated tests using Sahi Pro and currently we test only in English as the scripts were recorded in English and we can not rework for all the languages.

I somewhat agreed with what he was saying but at the same time, testing on all the available languages was also important. That motivated me to write an article which will help people facing the similar issue. I knew Sahi Pro is the tool which provides Multi Language Support.

Let's take as an example to understand the concept. Now,

1. We have the application which supports multi language -
2. We have the tool which supports the localization testing - Sahi Pro

Now, let see how it actually works.

In most applications, Internationalization (I18N) and Localization (L10N) are done by specifying constant keys in web application code, and then having another layer substitute these constant keys with the correct language translations provided via property files.
These translations are normally stored in properties files. Eg. (english), (hindi) etc.

I recorded the script on Google English and here it is.

_navigateTo(" ");
_assertVisible(_submit("Google Search"));
_click(_link("Google apps"));
_assertVisible(_span("My Account"));
_click(_link("Sign in"));
_setValue(_emailbox("identifier"), "shah.pratik123");

and the logs of the script execution.


As mentioned above, you would need file for localization/internationalization testing. Ideally, these property files should already be present with the developers. Here, unfortunately, I am not a Google Developer, hence I had to create these properties files. I will use file and file. The content of these files are as following:

GOOGLE_APPS=Google ऐप्लिकेशन
MY_ACCOUNT=मेरा खाता
BTN_SIGN_IN=प्रवेश करें

GOOGLE_APPS=Google apps
SIGN_IN=Sign in

Now, I will modify the above-recorded script a little bit for Multi Language Support. Sahi Pro uses _setLanguage() API to translate the languages. I want the same recorded script to be executed in Hindi Language.
_navigateTo(" ");
_setLanguage("", "");
_assertVisible(_submit("Google Search"));
_click(_link("Google apps"));
_assertVisible(_span("My Account"));
_click(_link("Sign in"));
_setValue(_emailbox("identifier"), "");
_setValue(_password("Passwd"), "aa");

Here, I had to click on हिन्दी link, so that Google will show the page in Hindi. You just need to launch the URL of your application which is in a different language.

The logs of this script execution are as follows:


Let's see how it works. It will navigate to the and click on the Hindi link so that the content will be converted to Hindi language. Our script makes use of the English words as it was earlier recorded for English.

We are using _setLanguage() API to translate the language from English to Hindi.

All the strings will be first picked up. In here, the first string after the _setLanguage() is "Google Search" , it will be looked in the file and it will find the key for that string. In this case, the key is GOOGLE_SEARCH . Now GOOGLE_SEARCH will be searched in the as a key and against this key, the value will be determined i.e Google खोज and the statement will be created from

_assertVisible(_submit("Google Search"));


_assertVisible(_submit("Google खोज"))

It will perform the same action for the rest of them. There are other keywords like 'L' for literals 'K' for Keywords.

You can find more information on this at

Hope this helps.

Sign In or Register to comment.