首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尝试在标题模式下运行剧作家测试时出错

尝试在标题模式下运行剧作家测试时出错
EN

Stack Overflow用户
提问于 2022-02-22 09:49:39
回答 1查看 3.7K关注 0票数 1

我在尝试运行这个简单的剧作家测试时出错了。在无头模式下工作很好,但在尝试以头模式运行时却给我带来麻烦。我可能缺少了一些依赖关系??

example.spec.ts

代码语言:javascript
复制
import { test, expect } from '@playwright/test'

test('Simple test',async ({ page }) => {
    await page.goto('https://www.example.com')

})

package.json

代码语言:javascript
复制
{
  "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"
  }
}

我所犯的错误

代码语言:javascript
复制
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 ==============================================================
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-22 13:34:41

看起来您在没有任何窗口管理器的linux上运行。可能是docker、wsl或您使用ssh (它不支持X11 (至少是开箱即用))。

设置一个窗口管理器,或者使用一个完整的桌面linux。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71219083

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档