How to use the pending-xhr-puppeteer.PendingXHR function in pending-xhr-puppeteer

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];

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