Running Protractor tests with multiple variable parameters via npm

We were facing a roadblock of running protractor tests on different environments using different configurations.

We tried different methods to fix this.

How we tackled this problem:

  1. We created empty parameters for each  variable paramter in protractor.conf.js
    params: {
    baseUrl: “”,
    url: “”,

    2. Protractor cli has support for running commands with parameters. For example We need to run tests on beta environment for some region with
    admin credentials. We ran below command:

    protractor e2e/protractor.conf.js –params.baseUrl ‘preview’ –params.user ‘raj’ –params.password ‘test’ –params.Status ‘beta'”

    As you can see that this command is pretty long and tough to remember we leveraged scripts functionality of npm.

    3. We added scripts in package.json like below:

    “scripts”: {
    “beta-n”: “protractor e2e/protractor.conf.js –params.baseUrl ‘beta’ –params.user ‘anil’ –params.password ‘pass’ –params.Status ‘beta'”,
    “beta-a”: “protractor e2e/protractor.conf.js –params.baseUrl ‘beta’ –params.user ‘raj’ –params.password ‘test’ –params.Status ‘beta'”


    4. In cli use below command to run tests on beta env with non admin user:

    npm run beta-n

    5. We can add scripts for different combinations.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s