How to run/deploy playwright on Heroku?

Akshay Mattoo
2 min readJan 11, 2022

--

Photo by Roman Synkevych on Unsplash

To start with what is playwright? Its a framework to enable end-2-end testing for web apps. But its not the only use case of playwright. Web scraping is also another use case we can use it for.

Doing scraping is very easy with playwright as it gives you an option where you can navigate through the workflow and it will generate the code for you. There are many languages support for that.

playwright inspector

you can get started with with the below command npx playwright codegen <url> . This will open the url entered and the playwright inspector and one has many options to select the language of choice code.

In the above example I opened google and searched javascript and one the right hand side it generated code for that. Like this one can generate the code quickly.

Fast forward if you deploy the code on heroku. It fails to recognize the playwright package. As many I tried many different options and nothing worked until I found this stack overflow link.

All one has to do is add the playwright build pack. To run the playwright on Heroku the container needs the right build pack and order matters. Make sure its first and then running environment. In my case its node.

My app is exposed as an API and now I can use the playwright capabilities. Let me know if you have questions I am happy to help. Happy learning happy coding.

--

--

Akshay Mattoo

#Father #JS-Advocate #SoftwareEngineer #fitnessbeliever #intermediatetennisplayer #lifebetweenthebraces{}