I'm trying to get my remote chrome driver to request pages in German instead of English. Following the chromedriver documentation and list of chrome preferences, I tried to set it like this:
capabilities.setCapability(ChromeOptions.CAPABILITY, getChromeOptions());
Map<String, String> chromePrefs = new HashMap<String,String>();
chromePrefs.put("settings.language.preferred_languages", "de-DE,de");
capabilities.setCapability("chrome.prefs", chromePrefs);
And I can see it reaches chromedriver from the log file:
[0.453][FINE]: Initializing session with capabilities {
"browserName": "chrome",
"chrome.prefs": {
"settings.language.preferred_languages": "de-DE,de"
},
"chromeOptions": {
"args": [ "--ignore-certificate-errors" ],
"extensions": [ ]
},
"platform": "ANY",
"version": null
}
But it still requests english pages and this can also be seen by opening the content settings in the preferences. What am I doing wrong?
(Edit) Long story short:
intl.accept_languages
is the preferences key to manipulate what languages are requested for a page.Set the capability for the preferences using the (newer and preferred) ChromeOptions
mechanism (otherwise it won't work if any ChromeOptions are set by you or your language bindings, see Issues 104 & 95).
ChromeOptions support for setting preferences is not completely implemented yet. So, unfortunately, you have to use the dirty workaround from my comment 6 to Issue 95
An alternative might be to create a user profile with the desired language settings and use ChromeOption to set the (command line) option to use this profile, as mentioned on the chromedriver capabilities wiki page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With