Troubleshooting

    Playwright passes flag by default and will fail to launch when such policies are active.

    To work around this, try running without the flag:

    Chrome headless doesn’t launch on Linux/WSL

    Make 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

    1. gconf-service
    2. libasound2
    3. libatk1.0-0
    4. libatk-bridge2.0-0
    5. libc6
    6. libcairo2
    7. libcups2
    8. libdbus-1-3
    9. libfontconfig1
    10. libgcc1
    11. libgconf-2-4
    12. libgdk-pixbuf2.0-0
    13. libglib2.0-0
    14. libgtk-3-0
    15. libnspr4
    16. libpango-1.0-0
    17. libpangocairo-1.0-0
    18. libstdc++6
    19. libx11-6
    20. libxcb1
    21. libxcomposite1
    22. libxcursor1
    23. libxdamage1
    24. libxext6
    25. libxfixes3
    26. libxi6
    27. libxrandr2
    28. libxrender1
    29. libxss1
    30. ca-certificates
    31. fonts-liberation
    32. libappindicator1
    33. libnss3
    34. lsb-release
    35. xdg-utils
    36. wget
    37. libgbm1
    38. ``` CentOS Dependencies

    pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc

    • - Debian troubleshooting

    • Puppeteer#391 - CentOS troubleshooting

    • - Alpine troubleshooting

    Please file new issues in this repo for things relating to Playwright.

    In 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 argument:

    1. const browser = await playwright.chromium.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']});

    NOTE: Running without a sandbox is strongly discouraged. Consider configuring a sandbox instead.

    [recommended] Enable user namespace cloning

    User 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.

    [alternative] Setup setuid sandbox

    The 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:

    1. # cd to the downloaded instance
    2. cd <project-dir-path>/node_modules/playwright/.local-browsers/chromium-<revision>/
    3. sudo chown root:root chrome_sandbox
    4. sudo chmod 4755 chrome_sandbox
    5. # copy sandbox executable to a shared location
    6. sudo cp -p chrome_sandbox /usr/local/sbin/chrome-devel-sandbox
    7. # export CHROME_DEVEL_SANDBOX env variable
    8. export CHROME_DEVEL_SANDBOX=/usr/local/sbin/chrome-devel-sandbox

    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 headless doesn’t launch on Linux/WSL

    Make 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.

    Make 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 which is used to run our tests.

    If 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:

    1. await page.evaluate(`(async() => {

    ReferenceError: URL is not defined

    Please file an issue

    Playwright 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.