angular / protractor

E2E test framework for Angular apps
http://www.protractortest.org
MIT License
8.75k stars 2.31k forks source link

How to add modHeader for chrome browser in protractor #5279

Open umairnaz opened 5 years ago

umairnaz commented 5 years ago

Hi,

I am trying to use modHeader for chrome browser in my protractor test. This is my browser settings in protractor index.html file:

multiCapabilities: [{ browserName: 'chrome', chromeOptions: { args: ['incognito', '--no-sandbox', '--disable-infobars', '--disable-gpu', '--window-size=1200x800'], prefs: { // disable chrome's annoying password manager 'profile.password_manager_enabled': false, credentials_enable_service: false, password_manager_enabled: false, download: { prompt_for_download: false, directory_upgrade: true, default_directory: './downloads/' }, plugins: { // disable browser pdf viewer always_open_pdf_externally: true } } }

}],

Coregraph commented 5 years ago

Hi, I've solved this using the chromeOptions.extensions: [ ] in the multiCapabilities.

First you need to download the modHeader extension .crx file. Then you have to read this file and pass them to the extension array as base64 String. This is an example of that process https://stackoverflow.com/questions/27278222/is-it-possible-to-add-a-plugin-to-chromedriver-under-a-protractor-test

With that you can use the modHeader plugin in the browser that is executing the test (I've been using this method in a local webdriver-manager, or a Selenium standalone or grid).