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" 
  cp -R $XDG_CACHE_HOME/playwright/ $PLAYWRIGHT_BROWSERS_PATH
else 
  echo "...Storing Playwright Cache in Build Cache" 
  cp -R $PLAYWRIGHT_BROWSERS_PATH $XDG_CACHE_HOME
fi

Can anyone confirm this works?

Hi,

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

Alan

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.