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();
options.addArguments('--lang=es');
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?
--lang=es
options usually works. Try to see if you add theAccept-Language
header. – LittlePanda May 13 '15 at 16:22