Demos of the Chrome DevTools Protocol for various testing/automation techniques. For simplicity, these demos use Puppeteer to interact with the Chrome DevTools Protocol.
These demos were originally used in a talk given at Nordic.js. You can view the talk slides on Notist.
In order to setup the demos for use, run the following commands (assuming you have git and npm installed):
git clone https://github.com/trentmwillis/devtools-protocol-demos.git
cd devtools-protocol-demos
npm install
From there you can run the various demos using npm run
and then the corresponding script name as documented below.
There are two types of demos in this repository:
- Service Demos - These are demos that use Puppeteer to power an API service to automate some workflow.
- Testing Demos - These are demos that use Puppeteer to test some aspect of a web application.
The Service Demos showcase Puppeteer-powered APIs. You can run them with npm run service<name>
.
static-site-api
- Creates a RESTful API for getting content from a statically generated site. After starting the service, go tohttp://localhost:3000
to get a random post from my blog.screenshot-emailer
- Creates a service where you can email a screenshot of a webpage to someone. You'll need a Gmail account in order for this demo to work.playback
- Creates a service where you can post a series of commands and Puppeteer will "playback" those commands. After starting the service, you can runservice-demos/playback-demo-script.js
in the browser to see it work.
The Testing Demos showcase testing various aspects of the ChitChat web application. You can run them with npm run test:<name>
.
intro
- A basic introduction showing launching the browser, visiting a page, and checking for an element's text.user-flow
- Builds on theintro
demo and runs through a user flow for sending messages in the app.accessibility
- Builds on theuser-flow
demo and checks the accessibility of the page usingaxe-core
.visual-regression
- Builds on theaccessibility
demo and checks the visual appearance of the app by using screenshots.memory-leak-by-heap
- Demonstrates a simple approach to detecting memory leaks by looking at the JS heap size of the app before and after a series of actions.memory-leak-by-prototype
- Demonstrates detecting memory leaks by checking for objects of a specific prototype in the app's memory.code-coverage
- Shows how to get code coverage (usage) reports for the assets used by a web app. Runs a test and then uses Istanbul to generate the report.multi-user
- Demonstrates how to launch multiple instances of an application to test multi-user interactions.multi-user-full
- Demonstrates how to launch multiple instances of an application to test multi-user interactions with accessibility, memory, and code coverage checks as well.