將 Playwright 專案包裝在 Docker 映像中后出現一些錯誤。我在 Playwright 中使用 Firefox。
檔案
FROM mcr.microsoft.com/playwright:next
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npx playwright install
CMD ["node","index.js"]
Package.json 依賴項
"@extra/humanize": "^4.2.2-next.616",
"playwright": "^1.15.0",
"playwright-extra": "^4.2.1-next.616"
索引.js
const { firefox } = require('playwright');
(async () => {
const browser = await firefox.launch();
const page = await browser.newPage();
await page.goto('http://whatsmyuseragent.org/');
await page.screenshot({ path: `example.png` });
await browser.close();
})();
它構建良好,但是當我運行它時,我收到此錯誤:
browserType.launch: Protocol error (Browser.enable): Browser closed.
==================== Browser output: ====================
<launching> /ms-playwright/firefox-1225/firefox/firefox -no-remote -headless -profile /tmp/playwright_firefoxdev_profile-q4UuZi -juggler-pipe -silent
<launched> pid=965
[err] *** You are running in headless mode.
[err] [Parent 965, Main Thread] WARNING: failed to seal memfd: Invalid argument: file /mnt/actions-runner/_work/playwright-internal/playwright-internal/browser_patches/firefox/checkout/ipc/chromium/src/base/shared_memory_posix.cc:461
[err] [Parent 965, Main Thread] WARNING: freezeable shared memory was never frozen: file /mnt/actions-runner/_work/playwright-internal/playwright-internal/browser_patches/firefox/checkout/ipc/chromium/src/base/shared_memory_posix.cc:543
更新:
如果有人遇到同樣的問題,我很遺憾地發現 Docker 映像在 MacBook M1(我正在運行)上無效:(
uj5u.com熱心網友回復:
正如您已經說過的,這是一個錯誤(現在在功能請求中),因為 MS Devs 提供的 docker 檔案在 M1 Mac 上失敗。
這是功能請求的鏈接 - https://github.com/microsoft/playwright/issues/7723
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/314685.html
