Localization Testing using Selenium Webdriver (Basic Tips)

Localization Testing using Selenium Webdriver is necessary when working with international web applications. We need to test those web apps in many different languages. Our test automation codes have to be run in each local chapter of the application or website. You can also think this as globalization testing as well. They are well described on here.

Localization Testing Real Life Scenario

Real Life Scenario: Sometimes, websites have an option to change its language independent from the browser’s language.  Some of them change the web app’s language according to the browser’s local settings.

Question: So how to change your browser’s language for multi-language tests in Selenium Webdriver?

Solution: All you need to do is to provide the necessary ChromeOptions or FirefoxOptions objects into your drivers.

localization testing

Chrome Driver Options

HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
chromePrefs.put("intl.accept_languages", language);
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", chromePrefs);
driver = new ChromeDriver(options);

Firefox Driver Options

FirefoxOptions options = new FirefoxOptions();
options.addPreference("intl.accept_languages", language);
driver = new FirefoxDriver(options);

Language parameter can be:

en English
de German
tr Turkish
es Spanish

 
Happy multi-language testing in Selenium Webdriver projects. Now, you can do localization testing using Selenium Webdriver without any pain. :)

Thanks.
Canberk Akduygu

3 thoughts on “Localization Testing using Selenium Webdriver (Basic Tips)”

  1. Hello,thank you for your document.I’m a coder from china. Recently I’ve met a problem. I set chrome driver options like you said in my code, but whatever the language parameter I use, “en”, “English”, “en-US”, “en_US”, it doesn’t seem to work and the diver take me to the page in Chinese. I don’t know if my code is wrong or the option is not avalible now. Could you please give me some advice ?

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.