How to set the browser language using selenium webdriver (Internationalization)


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’
profile.setPreference(“intl.accept_languages”,”fr”);
driver = new FirefoxDriver(profile);
driver.get(“http://google.co.in”);
Using Chrome Browser :

System.setProperty(“webdriver.chrome.driver”,”D:/DollarArchive/chromedriver.exe”);
ChromeOptions options = new ChromeOptions();
options.addArguments(“–lang= sl”);
ChromeDriver driver = new ChromeDriver(options);
driver.get(“http://google.co.in”);

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

Advertisements

3 thoughts on “How to set the browser language using selenium webdriver (Internationalization)

  1. Arun July 26, 2015 / 1:46 pm

    Thanks for the information dude, It helped me a lot.

    Like

  2. Shabe Noor August 4, 2015 / 10:39 am

    Great work .realy great job.
    Keep it up.

    Liked by 1 person

  3. NISHANT March 16, 2016 / 10:08 pm

    Is there any workaround for Internet Explorer too ? I know that you have mentioned that it is not possible but if you could help I would appreciate.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s