Activating chrome language flags when activating from protractor (selenium)

我们两清 提交于 2020-01-11 05:26:27

问题


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


回答1:


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" }



回答2:


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']}
    }


来源:https://stackoverflow.com/questions/26872481/activating-chrome-language-flags-when-activating-from-protractor-selenium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!