Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/playwright-community/heroku-playwright-example
Example for running Playwright with Chromium and Firefox on Heroku
https://github.com/playwright-community/heroku-playwright-example
chromium firefox heroku playwright
Last synced: about 1 month ago
JSON representation
Example for running Playwright with Chromium and Firefox on Heroku
- Host: GitHub
- URL: https://github.com/playwright-community/heroku-playwright-example
- Owner: playwright-community
- Created: 2020-05-16T15:31:52.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-12-13T05:20:56.000Z (about 2 years ago)
- Last Synced: 2024-05-01T17:23:45.575Z (8 months ago)
- Topics: chromium, firefox, heroku, playwright
- Language: HTML
- Homepage: https://heroku.playwright.tech
- Size: 52.7 KB
- Stars: 20
- Watchers: 2
- Forks: 29
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-playwright - Heroku Playwright Example - Example using Playwright on Heroku. (Showcases)
README
# Heroku Playwright Example
This example demonstrates how to use Playwright with Chromium and Firefox on a Heroku environment.
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/mxschmitt/heroku-playwright-example)
## General
The setup is based on using the [Playwright Heroku Buildpack](https://github.com/mxschmitt/heroku-playwright-buildpack.git) which installs the necessary dependencies and adjusts the needed Playwright specific settings. It's required to run this before using the [NodeJS Buildpack](https://github.com/heroku/heroku-buildpack-nodejs), because otherwise the NPM dependencies won't be installed correctly.
## Components
In this minimal setup, we are using an Express web server, which accepts requests with the browser name and the URL as parameters. This demonstrates, that the setup works during the normal Dyno runtime. For a full reference, you can find the HTTP handler in the [`src/index.js`](./src/index.js) file. It's important to run Chromium with the `chromiumSandbox: false` flag, because Heroku has no usable sandbox functionality on their containers.
To see a live demonstration, you can checkout [heroku.playwright.tech](https://heroku.playwright.tech) or make requests to these URLs to see that a browser is launched, the specified URL is opened and a screenshot is taken and delivered to the user:
- Chromium: [heroku.playwright.tech/browser/chromium?url=https://microsoft.com](https://heroku.playwright.tech/browser/chromium?url=https://microsoft.com)
- Firefox: [heroku.playwright.tech/browser/firefox?url=https://github.com](https://heroku.playwright.tech/browser/firefox?url=https://github.com)## Best practises
It's common to only install the [browser-specific NPM packages](https://playwright.dev/#version=v1.1.1&path=docs%2Finstallation.md&q=download-single-browser-binary), which will reduce installation time and slug size on Heroku in the end, that should fix also the error that the slug size is too large.