typescript - Error al intentar ejecutar la prueba de playwright en modo con interfaz gráfica
Estoy teniendo un error al intentar ejecutar esta prueba sencilla de Playwright. Funciona bien en modo sin cabeza, pero me está dando problemas al intentar ejecutar en modo con interfaz. ¿Podría estar faltando algunas dependencias?
ejemplo.spec.ts
import { test, expect } from '@playwright/test'
test('Simple test',async ({ page }) => {
await page.goto('https://www.example.com')
})
package.json
{
"name": "test123",
"version": "1.0.0",
"description": "Automated Softwre Testing",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@playwright/test": "^1.19.1",
"prettier": "^2.5.1"
}
}
El error que estoy recibiendo
akritishahi@LAPTOP-KM9UAVQD:~/test123$ npx playwright test --headed
Running 1 test using 1 worker
✘ example.spec.ts:3:1 › Simple test (156ms)
1) example.spec.ts:3:1 › Simple test =============================================================
browserType.launch: Browser closed.
==================== Browser output: ====================
<launching> /home/akritishahi/.cache/ms-playwright/chromium-965416/chrome-linux/chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,AcceptCHFrame,AutoExpandDetailsElement --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-1w9YPx --remote-debugging-pipe --no-startup-window
<launched> pid=10366
[pid=10366][err] [10366:10366:0222/203334.001670:ERROR:ozone_platform_x11.cc(234)] Missing X server or $DISPLAY
[pid=10366][err] [10366:10366:0222/203334.001780:ERROR:env.cc(225)] The platform failed to initialize. Exiting.
=========================== logs ===========================
<launching> /home/akritishahi/.cache/ms-playwright/chromium-965416/chrome-linux/chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,AcceptCHFrame,AutoExpandDetailsElement --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-1w9YPx --remote-debugging-pipe --no-startup-window
<launched> pid=10366
[pid=10366][err] [10366:10366:0222/203334.001670:ERROR:ozone_platform_x11.cc(234)] Missing X server or $DISPLAY
[pid=10366][err] [10366:10366:0222/203334.001780:ERROR:env.cc(225)] The platform failed to initialize. Exiting.
============================================================
at Object._baseTest.extend.browser.scope [as fn] (/home/akritishahi/test123/node_modules/@playwright/test/lib/index.js:163:51)
at /home/akritishahi/test123/node_modules/@playwright/test/lib/fixtures.js:78:81
1 failed
example.spec.ts:3:1 › Simple test ==============================================================
Respuesta #1
Parece que estás usando Linux sin ningún gestor de ventanas. Probablemente Docker, WSL o estás usando SSH (eso no tendrá soporte para X11, al menos de forma predeterminada).
Configura un gestor de ventanas, o usa un Linux de escritorio completo.