Skip to content

Instantly share code, notes, and snippets.

@dhAlcojor
Created May 21, 2020 11:54
Show Gist options
  • Save dhAlcojor/e7ad4d9c4d3dad8f495578805a1abbf3 to your computer and use it in GitHub Desktop.
Save dhAlcojor/e7ad4d9c4d3dad8f495578805a1abbf3 to your computer and use it in GitHub Desktop.
Simple Playwright test not working
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();
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment