Testing the contents of a temporary element with protractor Testing the contents of a temporary element with protractor angularjs angularjs

Testing the contents of a temporary element with protractor


I hacked around this using the below code block. I had a notification bar from a 3rd party node package (ng-notifications-bar) that used $timeout instead of $interval, but needed to expect that the error text was a certain value. I put used a short sleep() to allow the notification bar animation to appear, switched ignoreSynchronization to true so Protractor wouldn't wait for the $timeout to end, set my expect(), and switched the ignoreSynchronization back to false so Protractor can continue the test within regular AngularJS cadence. I know the sleeps aren't ideal, but they are very short.

browser.sleep(500);browser.ignoreSynchronization = true;expect(page.notification.getText()).toContain('The card was declined.');browser.sleep(500);browser.ignoreSynchronization = false;


It turns out that this is known behaviour for protractor. I think it should be a bug, but at the moment the issue is closed.

The workaround is to use $interval instead of $timeout, setting the third argument to 1 so it only gets called once.


you should wait for your toast displayed then do other stepsbrowser.wait(function() {    return $('.toaster').isDisplayed();}, 20000);