Troubleshooting
#
Chromium#
Chrome headless doesn't launch on WindowsSome chrome policies might enforce running Chrome/Chromium with certain extensions.
Playwright passes --disable-extensions
flag by default and will fail to launch when such policies are active.
To work around this, try running without the flag:
Context: Puppetteer#3681.
#
Chrome headless doesn't launch on Linux/WSLMake sure all the necessary dependencies are installed. You can run ldd chrome | grep not
on a Linux
machine to check which dependencies are missing. For dependencies on Ubuntu, please refer to Dockerfile which is used to run our tests.
The common ones for Debian and CentOS are provided below.
Debian (e.g. Ubuntu) Dependencies
CentOS Dependencies
After installing dependencies you need to update nss library using this command
Check out discussions
- Puppeteer#290 - Debian troubleshooting
- Puppeteer#391 - CentOS troubleshooting
- Puppeteer#379 - Alpine troubleshooting
Please file new issues in this repo for things relating to Playwright.
#
Setting Up Chrome Linux SandboxIn order to protect the host environment from untrusted web content, Chrome uses multiple layers of sandboxing. For this to work properly,
the host should be configured first. If there's no good sandbox for Chrome to use, it will crash
with the error No usable sandbox!
.
If you absolutely trust the content you open in Chrome, you can launch Chrome
with the --no-sandbox
argument:
NOTE: Running without a sandbox is strongly discouraged. Consider configuring a sandbox instead.
There are 2 ways to configure a sandbox in Chromium.
user namespace cloning#
[recommended] EnableUser namespace cloning is only supported by modern kernels. Unprivileged user namespaces are generally fine to enable, but in some cases they open up more kernel attack surface for (unsandboxed) non-root processes to elevate to kernel privileges.
setuid sandbox#
[alternative] SetupThe setuid sandbox comes as a standalone executable and is located next to the Chromium that Playwright downloads. It is fine to re-use the same sandbox executable for different Chromium versions, so the following could be done only once per host environment:
You might want to export the CHROME_DEVEL_SANDBOX
env variable by default. In this case, add the following to the ~/.bashrc
or .zshenv
:
#
Firefox#
Firefox headless doesn't launch on Linux/WSLMake sure all the necessary dependencies are installed. You can run ldd chrome | grep not
on a Linux
machine to check which dependencies are missing. For dependencies on Ubuntu, please refer to Dockerfile which is used to run our tests.
#
WebKit#
WebKit headless doesn't launch on Linux/WSLMake sure all the necessary dependencies are installed. You can run ldd chrome | grep not
on a Linux
machine to check which dependencies are missing. For dependencies on Ubuntu, please refer to Dockerfile which is used to run our tests.
#
Code transpilation issuesIf you are using a JavaScript transpiler like babel or TypeScript, calling evaluate()
with an async function might not work. This is because while playwright
uses Function.prototype.toString()
to serialize functions while transpilers could be changing the output code in such a way it's incompatible with playwright
.
Some workarounds to this problem would be to instruct the transpiler not to mess up with the code, for example, configure TypeScript to use latest ECMAScript version ("target": "es2018"
). Another workaround could be using string templates instead of functions:
#
Node requirements#
ReferenceError: URL is not definedPlaywright requires Node 10 or higher. Node 8 is not supported, and will cause you to receive this error.
#
Please file an issuePlaywright is a new project, and we are watching the issues very closely. As we solve common issues, this document will grow to include the common answers.