I'd really like to write a Selenium WebDriver test that verifies text is localized. The localization code bases the strings it displays on navigator.language (or navigator.userLanguage for IE). I cannot figure out, however, how to launch a Chromium window for a different language.

I see this bug which sort of explains the problem (closed as not a bug): https://code.google.com/p/chromium/issues/detail?id=114606

Here's how I create the browser instance:

var webdriver = require('selenium-webdriver');
var chrome = require("selenium-webdriver/chrome");

var options = new chrome.Options();
var caps = options.toCapabilities();
var driver = webdriver.Builder().withCapabilities(caps).build();

I installed the Spanish language, but whereas navigator.languages includes es in its list, but even if I move it to the top of the preferences, en-US is still what navigator.language is set to.

Have any of you found a way to successfully write multi-language tests with Selenium WebDriver?

  • Ive seen that the --lang=es options usually works. Try to see if you add the Accept-Language header. May 13, 2015 at 16:22

3 Answers 3


This code is working fine for me :

     ChromeOptions options = new ChromeOptions();
     ChromeDriver wd;
     wd = new ChromeDriver(options);

Its changing the language, showing up as first preferred language.

  • Sorry did'nt notice the programming language. My code is in Java. If it is working in java then it also should work in other as well after changing the syntax. Nov 13, 2014 at 13:15
  • Looks like the same thing I tried.
    – Jacob
    Nov 13, 2014 at 18:51
  • Yes and its working perfectly. Nov 14, 2014 at 9:10
  • 2
    It's not working for me. navigator.language is still set to en-US. I'm running this on Linux; not sure if that makes a difference.
    – Jacob
    Nov 14, 2014 at 15:38
  • @Jacob Does it work when you add that flag manually to the command line? Maybe there's a bug in Chrome for Linux Apr 29, 2015 at 18:47

I resolved the error using this SO post.

The accepted answer from the question:

You can do it by adding Chrome's command line switches "--lang".

Basically, all you need is starting ChromeDriver with an ChromeOption argument --lang=es, see API for details.

The following is a working example of C# code for how to start Chrome in Spanish using Selenium.

ChromeOptions options = new ChromeOptions();
ChromeDriver driver = new ChromeDriver(options);

Java code should be pretty much the same (untested). Remember, locale here is in the form language[-country] where language is the 2 letter code from ISO-639.

public WebDriver getDriver(String locale){   
    System.setProperty("webdriver.chrome.driver", "driver/chromedriver.exe");
    ChromeOptions options = new ChromeOptions();
    options.addArguments("--lang=" + locale);
    return new ChromeDriver(options);

public void initializeSelenium() throws Exception{
    driver = getDriver("es"); // two letters to represent the locale, or two letters + country

This works for me in JavaScript:

import { Builder, By, Key, until } from "selenium-webdriver";
import chrome from "selenium-webdriver/chrome";

const example = async () => {
      const options = await new chrome.Options();
const driver = await new Builder().forBrowser("chrome").setChromeOptions(options).build();

      try {
        await driver.get("https://www.google.co.il");
      } finally {
        await driver.quit();
await example();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.