Make sure the item has disappeared into the protractor

For waiting purposes, I use this wait function:

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

How can I wait until an element disappears from the page? I have a project that has many modal windows, and since the elements are always presented on the page, I have difficulties and failures are checked from time to time because I used the wrong elements to wait. For example, I have an element that disappears when the modal window closes after pressing Enter:

<div class="modal-backdrop  in"></div>
+4
source share
3 answers

waitAbsent() , , , ​​ , .

specTimeoutMs, webdriver, StaleElementError.

: require('./waitAbsent.js'); onPrepare .

:

expect($('.modal-backdrop.in').waitAbsent()).toBeTruthy();
+4

ExpectedConditions - . browser.wait , invisibilityOf ( ) stalenessOf ( DOM) .

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

If an element is already present on the page, you can receive and mute callbacks: D, taking advantage of the fact that it browser.wait()checks the page until the function passed to it takes on value true.

browser.wait(function()
    {
        return browser.isElementPresent(by.repeater('recentName in recentNames').row(0)) //if element is already present, this line will evaluate to true
               .then(function(presenceOfElement) {return !presenceOfElement}); // this modifies the previous line so that it evaluates to false until the element is no longer present. 
    }, 10000);
+1
source

All Articles