Testing the contents of a temporary element with protractor

后端 未结 6 1716
清酒与你
清酒与你 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:27

    In case anyone is still interested, this code works for me with no hacks to $timeout or $interval or Toast. The idea is to use the promises of click() and wait() to turn on and off synchronization. Click whatever to get to the page with the toast message, and immediately turn off sync, wait for the toast message, then dismiss it and then turn back on sync (INSIDE the promise).

    element(by.id('createFoo')).click().then(function () {
        browser.wait(EC.stalenessOf(element(by.id('createFoo'))), TIMEOUT);
        browser.ignoreSynchronization = true;
        browser.wait(EC.visibilityOf(element(by.id('toastClose'))), TIMEOUT).then(function () {
          element(by.id('toastClose')).click();
          browser.ignoreSynchronization = false;
       })
    });
    

提交回复
热议问题