3

I'm currently using protractor for some tests. Unfortunately, I can't figure out a way to pass command line arguments to the actual driver being used.

For example, chromedriver.exe accepts '--whitelisted-ips' as a command line argument. Is there any way, in my protractor config, that I can pass this to chromedriver.exe?

Another example is, with MicrosoftWebDriver.exe, it has a flag called '--package' which allows me to pass the package id of the app to target. How would I get protractor launch the driver with those arguments?

I thought that maybe I could launch the standalone selenium server with an argument to launch the driver with those arguments, but from my investigation I couldn't find a way to make that happen.

Just to clarify, I'm not asking to pass command line arguments into protractor to use in my tests. I want the browser drivers being that are running (chromedriver.exe, firefoxdriver.exe, MicrosoftWebDriver.exe) to be run with specific command line arguments.

Gooztastic
  • 31
  • 1
  • 3
  • Possible duplicate of [How can I use command line arguments in Angularjs Protractor?](https://stackoverflow.com/questions/23135649/how-can-i-use-command-line-arguments-in-angularjs-protractor) – SiKing Jun 29 '17 at 23:00
  • Thanks for the link @SiKing, but not exactly what I was looking for. This is passing an argument so that they can be used in the test files, but I want to pass arguments to the actual driver.exe's that are being used. – Gooztastic Jun 29 '17 at 23:03

1 Answers1

1

Add the arguments to your config file as capabilities. This is a driver-specific property.

For Chrome/Chromedriver:

exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',
    specs: ['./tmp/specs/*.spec.js'],
    capabilities: {
        'browserName' : 'chrome',
        'goog:chromeOptions' : {
            args: ['--start-maximized']
        }
    }
}

For Firefox/Geckodriver (only changes shown):

capabilities: {
    'browserName' : 'firefox',
    'moz:firefoxOptions' : {
        args: ['-headless']
    }
}

MDN has a (very short) list of vendor-specific capabilities.

See https://sites.google.com/a/chromium.org/chromedriver/capabilities for more.

gimpf
  • 4,503
  • 1
  • 27
  • 40
M. Hudson
  • 889
  • 5
  • 11
  • But how can I do this for other browser's drivers? While this will definitely work for chrome, how can I do this for firefox and edge drivers? It doesn't seem to be supported for those other browsers. – Gooztastic Jun 30 '17 at 23:27
  • I believe, for Firefox, you need to use profiles; for example: `var firefoxProfile = new FirefoxProfile(); firefoxProfile.setPreference("browser.download.folderList", 2); firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false);` – M. Hudson Jul 03 '17 at 08:02