'Gitlab CI/CD for Playwright testcases working in local, but not while pushing
I am writing testcases for my project in Playwright. I have used GitLab for CI/CD and my config file goes this way
.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
It's working fine when I run it in local. But fails when I push code to GitLab and give MR.
The error message
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
Solution 1:[1]
The reason is simple, one of the URLs was not accessible from GitLab. Changed the url, now it is working fine
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Arun Kenjila |
