How can I use command line arguments in Angularjs Protractor?

0
0

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.

Thanks!

  • You must to post comments
0
0

In the reference config this section can be interesting:

  // 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
: 'Jane',
password
: '1234'
}
},

And you can access the params object like this in your code: browser.params.login.user

So in your case if you call protractor like this:

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

You can access these variables in your code like this:

browser.params.login.user and browser.params.login.password

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website