Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activating chrome language flags when activating from protractor (selenium)

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

like image 525
Alon1980 Avatar asked Nov 11 '14 19:11

Alon1980


2 Answers

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" }
like image 198
Leo Gallucci Avatar answered Nov 03 '22 19:11

Leo Gallucci


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']}
    }
like image 1
Alon1980 Avatar answered Nov 03 '22 19:11

Alon1980