Created
May 21, 2020 11:54
-
-
Save dhAlcojor/e7ad4d9c4d3dad8f495578805a1abbf3 to your computer and use it in GitHub Desktop.
Simple Playwright test not working
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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