How to use pending-xhr-puppeteer - 3 common examples

To help you get started, we’ve selected a few pending-xhr-puppeteer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eugeniosegala / snap-this / index.js View on Github external
const snapThis = async () => {

  console.log('Starting...');

  const browser = await puppeteer.launch({ headless: true, ignoreHTTPSErrors: true });

  console.log('Taking screenshots...');

  for (let i = 0; i < devices.length; i++) {

    process.stdout.write(`${parseInt(((i / devices.length) * 100))}%\r`);

    const page = await browser.newPage();

    const pendingXHR = new PendingXHR(page);

    await page.goto(url, { waitUntil: 'networkidle2' });

    await pendingXHR.waitForAllXhrFinished();

    if (withStorage) {
      for (let inc = 0; inc < localStorageData.length; inc++) {
        const name = localStorageData[inc].name;
        const data = localStorageData[inc].data;
        await page.evaluate(({name, data}) => {
          localStorage.setItem(name, data);
        }, {name, data});
      }
    }

    const device = devices[i];
github shirshak55 / scrapper-tools / src / waitForXhr.ts View on Github external
export default async (page, no_of_xhr_request = 1) => {
  const p = new pendingXHR(page)
  await Promise.all([
    pWaitFor(() => p.finishedWithSuccessXhrs.size >= no_of_xhr_request),
    pendingXHR.waitForAllXhrFinished(),
  ])
}
github shirshak55 / scrapper-tools / src / waitForXhr.ts View on Github external
export default async (page, no_of_xhr_request = 1) => {
  const p = new pendingXHR(page)
  await Promise.all([
    pWaitFor(() => p.finishedWithSuccessXhrs.size >= no_of_xhr_request),
    pendingXHR.waitForAllXhrFinished(),
  ])
}

pending-xhr-puppeteer

Small tool for wait that all xhr are finished in pupeteer

MIT
Latest version published 4 years ago

Package Health Score

48 / 100
Full package analysis