Login.js file
'use strict';
var testData = require('./testdata.json');
describe('LoginPage', function() {
var loginData = require('./testdata.json');
it("data.description", function () {
browser.get("http://custemea3.imshealth.com/GlobalDashboard/qaconsole");
browser.driver.sleep(8000);
browser.driver.findElement(by.xpath('/html/body/div[1]/undefined/div/ims-
form/div[2]/div/div[2]/dynamic-
component/form/div[1]/div[1]/input')).sendKeys(testData[0].username);
browser.driver.findElement(by.xpath('/html/body/div[1]/undefined/div/ims-
form/div[2]/div/div[2]/dynamic-
component/form/div[1]/div[2]/input')).sendKeys(testData[0].passwordField);
browser.driver.sleep(4000);
browser.driver.findElement(by.className('btn btn-success')).click();
browser.driver.sleep(8000);
});
});
I wrote the above code to read a pair of parameters from a json file. But, I am unable to read the parameters when I try to read multiple pairs of parameters like below:
testdata.json file
[
{
"username":"ims",
"passwordField":"123"
},
{
"username":"ims",
"passwordField":"ims"
}
]
since I am new to protractor I don't know how to modify my code to read multiple parameters. I tried foreach using arrays but it didn't work. Please help me out!