Reputation: 65
Im working with protactor 5.1.1 and chromedriver_2.27. When clicking on schedule button I want to wait until the message of "Scheduling complete" shows up . I have tried the following code (and the code that is commented as well) with no success. Every time protractor will continue regardless. Any ideas?
that.serviceFilter.sendKeys(serviceName).then(function() {
utilsObj.doActionWithWait(that.serviceRowInServiceList, function() {
utilsObj.doActionWithWait(that.pickFilteredService, function() {
that.pickFilteredService.click().then(function() {
that.selectAllBtn.click().then(function() {
that.actionBtn.click().then(function() {
that.scheduleBtn.click()
// //EC = protractor.ExpectedConditions;
// var aaa = element(by.xpath("//*[@id='SchedulingInProgress']"));
// browser.wait(function () {
// return EC.visibilityOf(aaa).call().then(function (present) {
// console.log('\n' + 'looking for element....')
// if (present) {
// console.log('\n' + 'element not found!')
// return true;
// } else {
// console.log('\n' + 'element found!!')
// return false;
// }
// });
// }, 50000);
});
browser.wait(function() {
return browser.driver.isElementPresent(by.xpath("//*[@id='SchedulingInProgress']"))
})
});
});
});
});
});
Upvotes: 1
Views: 225
Reputation: 65
Finally I've got the solution!
var EC = protractor.ExpectedConditions;
var elm = element(by.css("#SchedulingInProgress > div:nth-child(2) > div"));
browser.wait(EC.visibilityOf(elm), 50000);
expect(elm.getText()).toEqual('Scheduled 1 out of 1');
Upvotes: 0
Reputation: 3645
As the error message indicates you are using - isElementPresent()
incorrectly. Its a function on ElementFinder Object and not on driver.
InCorrect Usage - browser.driver.isElementPresent()
Correct Usage - browser.driver.FindElement().isElementPresent()
More details here. If your goal here is to wait till a particular element shows up .. You are on the right path - Use Expected Conditions and they fit into browser.wait
very nicely. You can do something like this - browser.wait(EC.visibilityOf(element), 5000); //wait for an element to become
clickable
Look here on its usage
Upvotes: 1