How can I use command line arguments in Angularjs Protractor?
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
passing base url from command line in protractor
Protractor provides it by default. You just have to declare the correct variable.
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'chrome'
},
specs: ['HomePageCtrl_spec.js'],
chromeOnly: true,
jasmineNodeOpts: {
onComplete: null,
isVerbose: false,
showColors: true,
includeStackTrace: true
},
onPrepare: function() {
browser.manage().window().setSize(1600, 1000);
},
baseUrl: 'test'
};
and then, you run the tests:
protractor Conf.js --baseUrl="https://XXXXX/YYY"
To use this url within your tests:
browser.get(browser.baseUrl)
Related Topics
Create <Div> and Append <Div> Dynamically
Differencebetween Parseint(String) and Number(String) in JavaScript
Incorrect Result in JavaScript Calculation
Is Onload Equal to Readystate==4 in Xmlhttprequest
Javascript: Uncaught Typeerror: Cannot Call Method 'Addeventlistener' of Null
Pass Arguments with Page.Evaluate
How to Set State of Response from Axios in React
How to Replace Selected Text with HTML in a Contenteditable Element
How to Create Document Objects with JavaScript
How to Implement Custom Sort to a Specific Column After Jqgrid Has Been Generated
What Is a Practical Use for a Closure in JavaScript
JavaScript Runtime Complexity of Array Functions
How to Call Fromlatlngtodivpixel in Google Maps API V3
Date.Setmonth' Causes the Month to Be Set Too High If 'Date' Is at the End of the Month