verify that element disappear in protractor

Sergey Teplyakov picture Sergey Teplyakov · Nov 27, 2014 · Viewed 8.1k times · Source

For wait purposes I use such kind of wait function:

    browser.wait(function()
    {
        return browser.isElementPresent(by.repeater('recentName in recentNames').row(0));
    }, 10000);

How I can wait for element to disappear from the page? I have project which have lots of modal windows and because elements are always presented on the page I have difficulties and test failures from time to time, because I used wrong elements to wait. For example I have such element which disappear when modal window closes after clicking Enter:

<div class="modal-backdrop  in"></div>

Answer

filoxo picture filoxo · Jul 2, 2015

Protractor's ExpectedConditions is the recommended way to do this now. You can use it in conjuction with browser.wait to create the wait condition for various states, among them invisibilityOf (if being hidden) or stalenessOf (if being removed from the DOM) an element.

browser.wait( EC.invisibilityOf( $('#selector') ), 5000 );