Testing the contents of a temporary element with protractor

后端 未结 6 1688
清酒与你
清酒与你 2021-01-04 09:12

I\'m trying to test the login page on my site using protractor.

If you log in incorrectly, the site displays a \"toast\" message that pops up for 5 seconds, then dis

6条回答
  •  隐瞒了意图╮
    2021-01-04 09:39

    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;
    

提交回复
热议问题