Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.
/ puppeteer-rpa Public archive

RPA orchestrator for puppeteer scripts.

Notifications You must be signed in to change notification settings

ardislu/puppeteer-rpa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

puppeteer-rpa

February 2023 Update

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

  1. Install Deno and git
  2. 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.

  1. Clone this repo
git clone https://github.com/ardislu/puppeteer-rpa.git
  1. cd puppeteer-rpa

Use

  1. Make a puppeteer recording by using Chrome DevTools' Recording feature (available in Chrome 89+ only)
  2. Copy the recording into a standalone file in the recordings folder
  3. deno run -A ./main.ts

Flags

  • 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 is false.
  • headless: same as the Puppeteer launch option. Boolean flag to run the browser in headless mode or not. Default value is false.
  • slowMo: same as the Puppeteer launch option. Number of milliseconds to slow down operations by (useful to see the operations). Default value is 0.
  • screenshot: boolean flag to take a screenshot at the end of the recording, before the browser is closed. Default value is false.

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

Notes