Rayrun

What are the different ways to manage browser downloads in Playwright?

Answer

Managing Browser Downloads in Playwright

If you're managing browser binaries separately and want to skip browser downloads, set the PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD variable before installation. Run this command:

PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npx playwright install

You can also opt for a hermetic install and place binaries in a local folder. Set the PLAYWRIGHT_BROWSERS_PATH environment variable. This command places the binaries in the specified location:

PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers npx playwright install

Remember, setting PLAYWRIGHT_BROWSERS_PATH doesn't change the installation path for Google Chrome and Microsoft Edge.

Playwright has a "stale browser removal" feature. By default, it keeps track of clients that use its browsers and deletes versions that are no longer needed. If you want to keep all installed browsers, set the PLAYWRIGHT_SKIP_BROWSER_GC environment variable to 1.

To uninstall browsers of your current Playwright installation (chromium, firefox, webkit), run:

npx playwright uninstall

To remove browsers from other Playwright installations on your system, pass the --all flag:

npx playwright uninstall --all

For the most up-to-date instructions, always refer to the official Playwright documentation.

References

Thank you!
Was this helpful?
Still have questions?

If you still have questions, please ask a question and I will try to answer it.

Related Discord Threads

Related Questions

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].