但它对铬起作用。
playwright: 1.8.0节点: 14.15 Ubuntu: 20.04
这是我的代码。
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();
}
})();发布于 2021-02-05 19:28:09
我解决了我缺少libgstreamer-plugins-bad1.0-0:amd64这个库
发布于 2021-05-09 22:23:28
在ubuntu20.04上,我在运行我的第一个playwright脚本时遇到错误:通过npm i -D playwright (playwright v1.10.0和v10.19.0)每个playwright install instructions安装后的node first_script.js
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();
})();我看到的错误包括:
根据几个bugs #1935 #2621,运行以下命令可以让我成功运行:
sudo apt-get install libgles2 gstreamer1.0-libav libharfbuzz-icu0 libwoff1 libgstreamer-plugins-bad1.0-0 libgstreamer-gl1.0-0 libwebp-dev
然后尝试在同一个ubuntu20.04 node second_script.js上用chrome(Chrome),firefox和webkit运行第二个脚本
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();
}
})();并得到错误:
文件/home/playwright/.cache/ms-playwright/firefox-1238/firefox/libxul.so:
已安装firefox并成功运行第二个脚本:
sudo apt-get install firefoxhttps://stackoverflow.com/questions/66054840
复制相似问题