Run a script for multiple urls

How to loop through multiple pages with Playwright

How to loop through multiple pages and urls with Playwright

From Playwright.dev

const { chromium } = require('playwright');  // Or 'firefox' or 'webkit'.

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();
  for (let currentURL of ['https://google.com', 'https://bbc.com']) {
    await page.goto(currentURL);
    const element = await page.waitForSelector('img');
    console.log('Loaded image: ' + await element.getAttribute('src'));
  }
  await browser.close();
})();

Next:

Previous:

Edit this page on Github