I'm writing end to end tests with Protractor for an angular website.
We have to support certain languages so I would like to init chrome using the --lang
flag and start it with some other language. I searched the web and couldn't find any example to how it can be done.
My only lead was some article I saw and understood that I need to add to Protractor config file the "capabilities" section and there I can define the "args" property.
Then tried to tinker with it but no luck.
Any help will be most welcome.
Thanks,
Alon
How to set Browser language and/or Accept-Language header
exports.config = {
capabilities: {
browserName: 'chrome',
chromeOptions: {
// How to set browser language (menus & so on)
args: [ 'lang=fr-FR' ],
// How to set Accept-Language header
prefs: {
intl: { accept_languages: "fr-FR" },
},
},
},
};
More examples:
intl: { accept_languages: "es-AR" }
intl: { accept_languages: "de-DE,de" }
As it turns out - the answer was in the docs all along. This is how you do it for chrome and i guess it similar for other browsers: inside the protractor.conf.js (for Spanish):
capabilities: {
browserName: 'chrome',
version: '',
platform: 'ANY',
'chromeOptions': {
'args': ['lang=es-ES']}
}
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