Playwright install with chromium

The recommended solution to install Playwright with chromium support is through a Docker file.

However, for Puppeteer we can just install it and handle the binaries cache with the PUPPETEER_CACHE_DIR env variable as recommended in this solution.

Can we do the same with Playwright, i.e. install it with deps and manage the location of the binaries with the PLAYWRIGHT_BROWSERS_PATH variable:

#!/usr/bin/env bash
set -e

yarn playwright install chromium

# Store/pull Playwright cache with build cache
if [[! -d $PLAYWRIGHT_BROWSERS_PATH]]; then 
  echo "...Copying Playwright Cache from Build Cache" 
  echo "...Storing Playwright Cache in Build Cache" 

Can anyone confirm this works?


If PLAYWRIGHT_BROWSERS_PATH is a var utilized by Playwright, then it looks like it may behave in a similar way to Puppeteer, have you tried it?

You’ve not mentioned which path you intend to set PLAYWRIGHT_BROWSERS_PATH to, I’d suggest /opt/render/project/playwright


This indeed works!

Please note it should be:
if [[ ! -d $PLAYWRIGHT_BROWSERS_PATH ]]; with a space before the !

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.