You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
waitFor and find* queries are supported but waitForElementToBeRemoved is not currently. It would be useful to add this async util to avoid having to write boilerplate code around waitFor and expect
waitForElementToBeRemoved seems to pass in a selector.
I'm needing to wait for an actual element to be removed. (I have a "continue" button on each stage of a form, and because of a
transition, there's a moment that you can see both "continue" buttons.)
Apparently, you can check if the elementHandle is still connected with await elementHandle.evaluate(el => el.isConnected)puppeteer/puppeteer#640 (comment)
Here's my generic function that you can include under the MIT license to wait for an actual elementHandle to be removed. I didn't write the sleep function... it should be generic enough, though...
This code seems to work as a generic function:
functionsleep(ms){returnnewPromise((resolve)=>{setTimeout(resolve,ms);});}asyncfunctionwaitForElementHandleToBeRemoved(elementHandle,waitMax=5000,waitStep=100){consttimeStart=newDate().valueOf();varelementVisible=true;vartimeNow=timeStart;while((timeNow-timeStart)<waitMax&&elementVisible){awaitsleep(waitStep);elementVisible=awaitelementHandle.evaluate(el=>el.isConnected);timeNow=newDate().valueOf();}if(!elementVisible)returntrue;thrownewError('element still visible after '+waitMax+'ms');}
waitFor
andfind*
queries are supported butwaitForElementToBeRemoved
is not currently. It would be useful to add this async util to avoid having to write boilerplate code aroundwaitFor
andexpect
waitForElementToBeRemoved - DOM Testing Library
The text was updated successfully, but these errors were encountered: