We have protractor-cucumber framework as e2e test. Till now we use the conf file with statically mentioning the environment details inside the conf json. I would like to pass user defined arguments with the protractor_conf file something like below.
protractor protractor_conf.js -DbrowserName=chrome -DexecPlatform=(native/sauce)
and would like to fetch this argument inside the conf.js and substitute under the capabilities section. I could not get proper details on net, so any help/suggestions would be appreciated.
You could split the configuration up into multiple config files. For example protractor-chrome.conf.js:
You can add Parameters in your conf.js file then pass the arugs from the command line.
Here is an example.
Now from we can pass the arugs from command line
Next, you can also refer these parameters in your spec file.
There are multiple advantages to having a parameter setup.
This will be similar to 2nd example but uses the config file directly.
Then in your package.json script like this:
You can use
process
api to parse the arguments in cmd line.Then you can run case as following: