How can I use a parameter to a protractor configur

2019-06-07 13:23发布

问题:

Following the lead of this question, I tried (naievely) to do this:

protractor test/features/protractor-conf.js --params.test_set=dev_test

and

protractor-conf.js:

exports.config = {
   // ...
  specs: [browser.params.test_set+'/*.feature'],

... but of course it doesn't work because browser is not defined at the time that the conf file is parse.

So how could I achieve this effect: passing a parameter to protractor that determines the specs?

回答1:

Use the --specs command-line argument:

--specs Comma-separated list of files to test

protractor test/features/protractor-conf.js --specs=dev_test/*.feature

Note that dev_test/*.feature would be passed into the protractor's command-line-interface which would resolve the paths based on the current working directory (source code).