This repo mainly served as a proof of concept when the recorder feature was first released in January 2021. Nowadays, Puppeteer itself has a replay library for this exact purpose and the DevTools recorder also has a built-in replay feature.
Simple orchestrator to execute and log puppeteer recordings for robotic process automation (RPA) purposes. Designed to execute scripts generated by Chrome DevTools' Recording feature (available in Chrome 89+ only).
- Install Deno and
git
- Install
deno-puppeteer
and a browser binary for Puppeteer to use:
Using bash
:
PUPPETEER_PRODUCT=chrome deno run -A --unstable https://deno.land/x/puppeteer@16.2.0/install.ts # For chromium
PUPPETEER_PRODUCT=firefox deno run -A --unstable https://deno.land/x/puppeteer@16.2.0/install.ts # For firefox
Using PowerShell
(reference):
# For chromium
try {
$oldValue = $env:PUPPETEER_PRODUCT
$env:PUPPETEER_PRODUCT = "chrome"
deno run -A --unstable https://deno.land/x/puppeteer@16.2.0/install.ts
}
finally {
$env:PUPPETEER_PRODUCT = $oldValue
}
# For firefox
try {
$oldValue = $env:PUPPETEER_PRODUCT
$env:PUPPETEER_PRODUCT = "firefox"
deno run -A --unstable https://deno.land/x/puppeteer@16.2.0/install.ts
}
finally {
$env:PUPPETEER_PRODUCT = $oldValue
}
Reference deno-puppeteer for more details.
- Clone this repo
git clone https://github.com/ardislu/puppeteer-rpa.git
cd puppeteer-rpa
- Make a puppeteer recording by using Chrome DevTools' Recording feature (available in Chrome 89+ only)
- Copy the recording into a standalone file in the
recordings
folder deno run -A ./main.ts
dir
,D
: the directory where the puppeteer recordings are located. Default value is./recordings
.exec
,E
: the recordings to execute. Default value is*.js
.sync
: boolean flag to run the recordings synchronously or in parallel. Default value isfalse
.headless
: same as the Puppeteer launch option. Boolean flag to run the browser in headless mode or not. Default value isfalse
.slowMo
: same as the Puppeteer launch option. Number of milliseconds to slow down operations by (useful to see the operations). Default value is0
.screenshot
: boolean flag to take a screenshot at the end of the recording, before the browser is closed. Default value isfalse
.
Examples:
# Run all the *.js files from the ./recordings folder in parallel
deno run -A ./main.ts
# Run example1.js and example2.js from the ./example-directory folder
deno run -A ./main.ts --dir ./example-directory --exec example1.js,example2.js
# Use a wildcard to match recordings with a specific name from the ./recordings folder
deno run -A ./main.ts -E example*.js
# Run all the recordings from the ./recordings folder one at a time (i.e. synchronously)
deno run -A ./main.ts --sync
# Run all the recordings from the ./recordings folder in headless mode and take screenshots
deno run -A ./main.ts --headless --screenshot
- Example recordings are included for completing the forms on jec.fyi and rpachallenge.