Puppeteer
Automated Web Testing and Monitoring with Puppeteer
Last updated
Automated Web Testing and Monitoring with Puppeteer
Last updated
Install Puppeteer using npm or yarn.
Add the Chrome Recorder Extension to your browser.
Open your favorite code editor (for example VSCode), and create files under the .js extension.
Record the Puppeteer Script. Unlike Playwright, Puppeteer does not have an inbuilt Recorder, but, you can use Chrome DevTools to record browser actions to generate a Puppeteer Script.
Enable Recording:
To access Developer Tools in Chrome, click on the More Options Icon located in the upper right corner and select it from the More Tools option.
To access the Recorder in Developer Tools, simply click on the More Options Icon and select it from the More Tools option.
After enabling the Recorder, you can start recording browser actions performed on the browser window.
Record and Export the Script:
For this example, we will be performing the following actions and exporting the recordings to the Puppeteer Script:
Start from the Google Search page.
Search for "PerfAgents".
Go to the PerfAgents Website.
Perform a few actions.
To Record, perform the following actions:
In the Recorder, click 'Create a new recording'.
Click on 'Start recording'.
Click 'End recording' to stop recording.
Click the 'Export' icon to export as Puppeteer.
Save the Script on your local machine.
Integrate with PerfAgents:
After recording, make sure to change the line
to
To take screenshots, include
To get screen recording import "PuppeteerScreenRecorder" and initialize recording inside the test block
To include multiple tests inside a single file, create each test as different functions
Validated files can be used to advance from the 'Install' step to the 'Frequency' step by uploading them.
Sequence monitoring now supports access to custom variables inside of test files as environmental variables
To use custom variables inside JavaScript or typescript fie