【问题标题】:Gitlab CI/CD for Playwright testcases working in local, but not while pushingGitlab CI/CD for Playwright testcases 在本地工作,但不是在推送时
【发布时间】:2023-02-10 16:53:19
【问题描述】:

我正在为我在 Playwright 中的项目编写测试用例。 我已经将 GitLab 用于 CI/CD 并且我的配置文件是这样的

.gitlab-ci.yml

image: mcr.microsoft.com/playwright:focal

variables:
  RP_TOKEN: "myToke"
  RP_LAUNCH: "myLaunch"
  RP_PROJECT_NAME: "myProject"

stages:
  - build
  - test

cache:
  paths:
    - project/node_modules/

install_dependencies:
  stage: build
  script:
    - cd project/
    - npx playwright install
    - npm install
  artifacts:
    paths:
      - project/node_modules/
  tags:
    - karate
  only:
    - merge_requests
    - schedules

test:
  stage: test
  script:
    - cd project/
    - npm install
    - npx playwright install
    - npm test
  only:
    - merge_requests
    - schedules

  tags:
    - karate

当我在本地运行时它工作正常。但是当我将代码推送到 GitLab 并给 MR 时失败了。

错误信息

browserType.launch: Browser closed.
==================== Browser output: ====================
<launching> /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-U1WHRn --remote-debugging-pipe --no-startup-window
<launched> pid=461
[pid=461][err] [461:461:0216/070734.862628:ERROR:ozone_platform_x11.cc(234)] Missing X server or $DISPLAY
[pid=461][err] [461:461:0216/070734.862710:ERROR:env.cc(225)] The platform failed to initialize.  Exiting.
[pid=461][err] [0216/070734.882276:ERROR:nacl_helper_linux.cc(315)] NaCl helper process running without a sandbox!
[pid=461][err] Most likely you need to configure your SUID sandbox correctly

【问题讨论】:

  • 我不是 gitlab 专家,但在文档中,图像位于测试部分 playwright.dev/docs/ci#gitlab-ci 你能测试一下吗?
  • Tnx @hardkoded ......我也试过......但没有运气..

标签: gitlab-ci playwright gitlab-ci.yml


【解决方案1】:

原因很简单,其中一个 URL 无法从 GitLab 访问。修改了url,现在可以正常使用了

【讨论】:

    【解决方案2】:

    我曾经有过类似的问题。确保您在管道中使用的图像中的工作目录是正确的。检查pwd管道中使用的工作目录,并与本地使用的工作目录进行比较。

    【讨论】:

      猜你喜欢
      • 2022-01-19
      • 2022-07-27
      • 2018-10-03
      • 1970-01-01
      • 2017-08-06
      • 2020-11-09
      • 2022-01-26
      • 2021-10-20
      • 2021-10-14
      相关资源
      最近更新 更多