Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (29.3k points)

I'm using Protractor to perform some end to end tests, and I'd like to pass in login credentials through the command line instead of storing them in a spec file. I found one post where someone used process.argv.forEach, but how can I store those values and use them in another spec file? I have a file called login-spec.js where I'd like to use the command-line arguments.

1 Answer

0 votes
by (50.2k points)

To give credentials to params use the below code

// The params object will be passed directly to the protractor instance,

  // and can be accessed from your test. It is an arbitrary object and can

  // contain anything you may need in your test.

  // This can be changed via the command line as:

  //   --params.login.user 'Joe'

  params: {

    login: {

      user: 'user',

      password: '12345'



Params object can be accessed by using 


Calling of protractor can be done using

protractor ... --params.login.user=abc --params.login.password=123

Variables can be accessed through 




Browse Categories