2

further to this Q & A, is it possible to pass a JSON object via the CLI? ie not via a config file? (rather than just passing a simple string)

ie

protractor ... --params={login: {user:"abc", password="abc123"}}

rather than:

protractor ... --params.login.user=abc --params.login.password=abc123
Community
  • 1
  • 1
ErichBSchulz
  • 15,047
  • 5
  • 57
  • 61

1 Answers1

1

Is not possible in current Protractor. As of this write current version is 1.0.0

But extending it yourself is quite simple. First you should pass valid JSON, so instead of

protractor ... --params={login: {user:"abc", password="abc123"}}

Pass it like this:

protractor ... --params='{"login": {"user":"abc", "password":"abc123"}}'

Then within your onPrepare section:

var argv = require('minimist')(process.argv.slice(2));
browser.params = JSON.parse(argv.params);

Oh, add "minimist": "~0.2" to your package.json or install globally.

Leo Gallucci
  • 16,355
  • 12
  • 77
  • 110