Search code examples
javascriptangularjstestingprotractorgrowl

Protractor (to test angular-growl) passing/failing inconsistently


I am trying to test that a growl message appears after a valid email is entered and the submit button is clicked.

I know the functionality is there, because I see the growl message appear when webdriver is running. The problem is capturing the growl message in the test.

I have tried putting the forgotPasswordPage.submitButton.click() both outside(before) and inside the browser.wait function. We have our growl configured to display the messages for 4 s so that's where I got the wait time. I'm looking for a way to make this test more reliable, and ideally I would be able to test the text that is actually inside the growl message, but first thing's first.

it('should display green growl message if user email does exist', function(){
    // uses testUsers[0]
    forgotPasswordPage.emailInput.sendKeys(testUsers[0].email);

    browser.wait(function() {
        forgotPasswordPage.submitButton.click();
        return element(by.css('.alert-success')).isPresent()
    }, 4000)
    .then(function(growlMessageIsPresent){
        expect(growlMessageIsPresent).toBeTruthy();
    })
    .then(null, function(err) {
        console.log('error', err)
        expect(err).not.toBeTruthy();
    })
})

Solution

  • We had a similar problem, trying to catch a status message which appeared for couple of seconds and then disappeared, which we had to approach turning the Protractor-to-Angular sync off temporarily:

    browser.ignoreSynchronization = true;