I am using protractor-cucumber framework with protractor 5.2.2. I have a requirement of post something in each location of any account and different accounts having different number of locations.And i am getting this location value from the DB(I have to click on this locations by its name).I have used below code for that.
request.query('SELECT * FROM Locations WHERE ID =1', function (loc) {
var loc_count=loc.length ;
var i;
for (i=0; i<loc_count; i++){
element(by.cssContainingText("span", loc[i].Location_name)).click();
browser.sleep(4000);
element(by.css('.post')).sendKeys("test");
element(by.css('.submit')).click();;
}
});
But here the asynchronous functions click()/sendKeys()/sleep() are not waiting.click()/sendKeys()/sleep() are executing for one or two locations and exit from the for loop and then executing the next feature step. So how can i execute this loop properly for all locations.Thanks in Advance.