Is there any way or Puppeteer API we can wait element to disappear or remove from Dom and then continue the execution?
E.g I have a loading animation I want to wait until this loading animation remove from Dom.
Is there any way or Puppeteer API we can wait element to disappear or remove from Dom and then continue the execution?
E.g I have a loading animation I want to wait until this loading animation remove from Dom.
waitForSelector
has a hidden
option which also check if the element is in the DOM:
await page.waitForSelector('div', {hidden: true});
Try this
await page.waitForFunction(() => !document.querySelector(querySelector));
If you're waiting for API response, maybe it's better to rely on
await page.waitForResponse(response => response.url() === myUrl && response.status() === 200);
You can use page.waitForFunction with a conditional statement.
await page.waitForFunction('document.querySelector("#myElement") === null')