How to set the language using Selenium WebDriver

Internationalization is a process of designing a software application so that it can be adapted to various languages and regions without any changes

Localization is a process of adapting internationalized software for a specific region or language by adding local specific components and translating text.

If we want to check whether our application is properly internationalized , then we will manually change the language preferences in the browser itself. But if we want to check the same using WebDriver then we have to change the user language preferences.

Using Firefox Browser :
FirefoxProfile profile = new FirefoxProfile();
//setting the locale french : ‘fr’
driver = new FirefoxDriver(profile);

Using Chrome Browser :
ChromeOptions options = new ChromeOptions();
//setting the locale Slovenian language
options.addArguments("–lang= sl");
ChromeDriver driver = new ChromeDriver(options);

Unfortunately it wont work for IE browser, We need to change it manually.

No comments:

Post a Comment