But it works with chromium.
playwright: 1.8.0 node: 14.15 Ubuntu: 20.04
this is my code.
const playwright = require("playwright");
(async () => {
for (const browserType of ["chromium", "firefox", "webkit"]) {
const browser = await playwright[browserType].launch();
const context = await browser.newContext();
const page = await context.newPage();
await page.goto("http://whatsmyuseragent.org/");
await page.screenshot({ path: `example-${browserType}.png` });
await browser.close();
}
})();
I solved it I was missing this library libgstreamer-plugins-bad1.0-0:amd64
On ubuntu 20.04, I was getting errors when running my first playwright script: node first_script.js
after installing via npm i -D playwright
(playwright v1.10.0 and v10.19.0) per playwright install instructions
const { webkit } = require('playwright');
(async () => {
const browser = await webkit.launch();
const page = await browser.newPage();
await page.goto('http://whatsmyuseragent.org/');
await page.screenshot({ path: `whatsmyuseragent.png` });
await browser.close();
})();
saw errors that included:
Per several bugs #1935 #2621 , running the following allowed me to run successfully:
sudo apt-get install libgles2 gstreamer1.0-libav libharfbuzz-icu0 libwoff1 libgstreamer-plugins-bad1.0-0 libgstreamer-gl1.0-0 libwebp-dev
then tried to run 2nd script with chrome(chromium), firefox and webkit on same ubuntu 20.04 node second_script.js
const playwright = require('playwright');
(async () => {
for (const browserType of ['chromium', 'firefox', 'webkit']) {
const browser = await playwright[browserType].launch();
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('http://whatsmyuseragent.org/');
await page.screenshot({ path: `example-${browserType}.png` });
await browser.close();
}
})();
and got errors:
installed firefox and 2nd script ran successfully:
sudo apt-get install firefox
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.