[Solved] WebDriver: How to specify preferred languages for Chrome
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?
Read more here: Source link