microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.17k stars 3.61k forks source link

[Question] Can't run Safari in Ubuntu (WSL) #6339

Closed Semigradsky closed 3 years ago

Semigradsky commented 3 years ago

Ubuntu 20.04.1 LTS playwright 1.10.0

I see that it possible by system requirements but I didn't find any specific steps.

I installed playwright and browsers locally by PLAYWRIGHT_BROWSERS_PATH=0 npm i playwright. After this I tries run it via PLAYWRIGHT_BROWSERS_PATH=0 npx playwright wk https://webkit.org/. There were messages about missed packages, I installed them by apt-get install.

After this I get this error message:

> safari@1.0.0 start /home/dmitry/P/safari
> PLAYWRIGHT_BROWSERS_PATH=0 DEBUG=pw:api npx playwright wk https://webkit.org/

  pw:api => browserType.launch started +0ms
  pw:api <= browserType.launch failed +239ms
browserType.launch: Protocol error (Playwright.enable): Browser closed.
==================== Browser output: ====================
<launching> /home/dmitry/P/safari/node_modules/playwright/.local-browsers/webkit-1446/pw_run.sh --inspector-pipe --no-startup-window
<launched> pid=20707
[pid=20707][err] Unable to init server: Could not connect: Connection refused
[pid=20707][err]
[pid=20707][err] (MiniBrowser:20712): Gtk-WARNING **: 21:06:44.413: cannot open display:
[pid=20707] <process did exit: exitCode=1, signal=null>
=========================== logs ===========================
<launching> /home/dmitry/P/safari/node_modules/playwright/.local-browsers/webkit-1446/pw_run.sh --inspector-pipe --no-startup-window
<launched> pid=20707
[pid=20707][err] Unable to init server: Could not connect: Connection refused
[pid=20707][err]
[pid=20707][err] (MiniBrowser:20712): Gtk-WARNING **: 21:06:44.413: cannot open display:
[pid=20707] <process did exit: exitCode=1, signal=null>
============================================================
Semigradsky commented 3 years ago

Error message looks similar to error in #2621

yury-s commented 3 years ago

npx playwright wk runs in headed mode but there is no display by default in linux running under WSL. You need to configure X server so that it forwards traffic from WSL to the host system or just run playwright in the host system.

If you want to stick with WSL2 you can try to use VcXsrv and configure it following instructions from this post.

Semigradsky commented 3 years ago

Thankyou for your response! Also this tutorial helped me.