Skip to content

Instantly share code, notes, and snippets.

@dhAlcojor
Created May 21, 2020 11:54
Show Gist options
  • Select an option

  • Save dhAlcojor/e7ad4d9c4d3dad8f495578805a1abbf3 to your computer and use it in GitHub Desktop.

Select an option

Save dhAlcojor/e7ad4d9c4d3dad8f495578805a1abbf3 to your computer and use it in GitHub Desktop.

Revisions

  1. dhAlcojor created this gist May 21, 2020.
    21 changes: 21 additions & 0 deletions index.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    const playwright = require('playwright');

    (async () => {
    for (const browserType of ['chromium', 'firefox', 'webkit']) {
    const browser = await playwright[browserType].launch();
    try {
    const context = await browser.newContext();
    const page = await context.newPage();
    await page.goto('https://google.com');
    await page.fill('input[name=q]', 'cheese');
    await page.press('input[name=q]', 'Enter');

    const firstResult = page.$('div#rso h3');
    console.log(`${browserType}: ${firstResult.textContent()}`);
    } catch(error) {
    console.error(`Trying to run test on ${browserType}: ${error}`);
    } finally {
    await browser.close();
    }
    }
    })();