Reputation: 2564
I have an application that is using Angular Growl v2 and in my protractor test I want to ensure that the growl event happens and that it contains the right text. So I have the following check:
var expectGrowlMessage = function(text) {
var growl = element(by.css('.growl-message'));
# Protractor stops here until growl div is removed
browser.wait(EC.presenceOf(growl), 3004, 'Waiting for growl to appear');
expect(growl.getText()).toContain(text);
browser.wait(EC.not(EC.presenceOf(growl)), 7002, 'Waiting for growl message to disappear');
};
What I can tell (via console.log
) is happening is that protractor will enter the expectGrowlMessage
and then stop before the first browser.wait
. In the browser, I can see the growl message so the first wait should succeed. Once the growl element is removed, THAT is when protractor proceeds to the first wait check, which will obviously fail.
I have tried browser.driver.wait
and browser.waitForAngular()
both of which don't seem to work.
Any suggestions on what Protractor is doing and how to get it to work??
Upvotes: 0
Views: 59
Reputation: 899
Try being specific about what order you want to do things, by use of "then":
var expectGrowlMessage = function(text, timeout = 3004) {
var growl = element(by.css('.growl-message'));
var EC = protractor.ExpectedConditions;
browser.wait(EC.presenceOf(growl), timeout).then(function(){
expect(growl.getText()).toContain(text);
});
});
Upvotes: 1