So, I am writing a protractor test to log into an app. When a user logs in successfully a popup notification appears stating "you have successfully logged in."
Right now I am doing a browser.sleep()
to wait for the popup to pop up after the login button is clicked. I don't like doing this, on slower networks Protractor is not waiting long enough and the test is failing when I try to catch the popup or alert because alert.accept()
is running too soon.
Is there a way to wait the promise from the login to return to continue on with the test?
UPDATE:
I think that I have figured it out. So I'm doing this:
LoginView.loginButton.click().then(function () {
browser.wait(exc.alertIsPresent()).then(function () {
App.catchAlert();
})
});
This seems to be working, but I haven't tested it on a slower network. What do you think?