Dev Tips: DevTools: Record tests with the puppeteer recorder

Dev Tips

 

DevTools: Record tests with the puppeteer recorder 🎥️

 


Introduction

The Puppeteer Recorder feature in Chrome DevTools can monitor your webpage interactions and generate the code to automate a browser.

For example, if you click on an element and type an email address into an email field, the recorder can generate the following code:

await page.click("aria/Login");
await page.type("aria/Email", "umar.hansa@gmail.com");

How to use this feature

Please note: Upon testing, there are a number of bugs with this feature, hence why it's experimental in Chrome Canary!

To get started, follow these instructions:

  1. Enable the Recorder experiment from the Experiments Panel (Select Show Experiments from the Command Menu with Cmd + Shift + P).
  2. Reload DevTools with Alt + R.
  3. Select Add Recording from the Sources Panel > Recordings Pane.
  4. Select the Record button and click on the webpage.
  5. Select the Record button to stop recording.
  6. Observe DevTools generates Node.js code which controls puppeteer.


At this point, you can

  • Save the generated test code onto your filesystem.
  • Copy and paste it into your code editor.
  • Edit the generated code in place (e.g. to add an assertion).
  • Append to the current code by selecting the Record button again.
 

When to use this feature

Test generators can automatically write automation code based on your actions in a webpage. They're great, but just like with testing frameworks, they can have their own limitations. For example, they need supervision - the code it generates is not your final test file, you'll still need to ensure:

  • Selectors are appropriate and maintainable.
  • waits/pauses are added if needed.
  • Assertions are added in (assuming you're writing a test)
  • Best practices are still being used.

That being said, the DevTools Recorder, and the recorders listed below in the "Extra" section, are extremely helpful for producing scaffolding-style code which would otherwise be tedious to write. Using it as a boilerplate for a new test file is worth doing.
 

Extra

  • If you're interested in browser automation, I've got a GitHub repo which is full of lots of examples, including test generators - it's for an upcoming course, so stay tuned!
  • Playwright (a puppeteer alternative) has it's own recorder, the Playwright CLI.
  • Here's the work-in-progress Puppeteer Recorder.

See this tip online: umaar.com/dev-tips/241-puppeteer-recorder
 
Email Marketing Powered by Mailchimp

Copyright © 2020 Umar, All rights reserved.
You are receiving this email because you signed up for Dev Tips.

unsubscribe from this list    update subscription preferences 

Older messages

Dev Tips: DevTools: Refactor your styles with CSS Overview

Wednesday, November 18, 2020

View different metrics on your styles and improve your overall CSS architecture Dev Tips DevTools: Refactor your stylesheets with CSS Overview Introduction The CSS Overview Panel provides interesting

Dev Tips: DevTools: Create your own keyboard shortcuts  ⌨️

Friday, November 13, 2020

The Shortcut Editor lets you assign your own preferred keyboard shortcuts to common workflows. Dev Tips DevTools: Create your own keyboard shortcuts ⌨️ Introduction The DevTools Shortcut Editor lets

Dev Tips: DevTools: The New Media Panel  🎬

Wednesday, November 4, 2020

The Media Panel in DevTools provides useful video inspection tools, useful for debugging, understanding, and learning about video. Dev Tips DevTools: The New Media Panel 🎬 I've written an article

Dev Tips: DevTools: CSS Grid Inspection ✨

Wednesday, October 28, 2020

Dev Tips DevTools: CSS Grid Inspection ✨ Hey everyone! I took a little break, but I'm back and I've got some great tips to share with you over the next few weeks! Introduction CSS Grid

Dev Tips: DevTools: Accessible colour suggestions  🎨

Friday, September 4, 2020

Get accessible colour suggestions for low contrast text Dev Tips DevTools: Accessible colour suggestions I'll be doing an AMA in a few hours! Feel free to ask anything you're curious about!

You Might Also Like

Charted | Global Economic Confidence in 2025, by Country 🌎

Wednesday, December 25, 2024

While emerging markets in Asia have the strongest confidence in the global economy looking ahead, European countries are most pessimistic. View Online | Subscribe | Download Our App FEATURED STORY

Top Tech Deals 🎅 Sony Headphones, iPhone Cases, 4K Projector, and More!

Wednesday, December 25, 2024

The season of giving is upon us. How-To Geek Logo December 25, 2024 Top Tech Deals: Sony Headphones, iPhone Cases, 4K Projector, and More! The season of giving is upon us. Happy Holidays! If you're

Why the Race to AGI is Humanitys Defining Moment

Wednesday, December 25, 2024

Top Tech Content sent at Noon! Boost Your Article on HackerNoon for $159.99! Read this email in your browser How are you, @newsletterest1? 🪐 What's happening in tech today, December 25, 2024? The

Iran's Charming Kitten Deploys BellaCPP: A New C++ Variant of BellaCiao Malware

Wednesday, December 25, 2024

THN Daily Updates Newsletter cover The Data Science Handbook, 2nd Edition ($60.00 Value) FREE for a Limited Time Practical, accessible guide to becoming a data scientist, updated to include the latest

Software Testing Weekly - Issue 251

Wednesday, December 25, 2024

GitHub Copilot is free! 🤖 View on the Web Archives ISSUE 251 December 25th 2024 COMMENT Welcome to the 251st issue! In case you missed it — GitHub Copilot is free! The free version works with Visual

Daily Coding Problem: Problem #1647 [Medium]

Tuesday, December 24, 2024

Daily Coding Problem Good morning! Here's your coding interview problem for today. This problem was asked by Square. In front of you is a row of N coins, with values v 1 , v 1 , ..., v n . You are

Sentiment Analysis, Topological Sort, Web Security, and More

Tuesday, December 24, 2024

Exploring Modern Sentiment Analysis Approaches in Python #661 – DECEMBER 24, 2024 VIEW IN BROWSER The PyCoder's Weekly Logo Exploring Modern Sentiment Analysis Approaches in Python What are the

🤫 Do Not Disturb Mode Is My Secret to Sanity — 8 Gadgets I Want To See Nintendo Make

Tuesday, December 24, 2024

Also: The Best Christmas Movies to Watch on Netflix, and More! How-To Geek Logo December 24, 2024 Did You Know Their association with the Christmas season might make you think poinsettias hail from a

😱 AzureEdge.net DNS Retiring Jan. 2025, 🚀 Microsoft Phi-4 AI Outperforms, 🔒 Microsoft Secure Future Initiative

Tuesday, December 24, 2024

Blog | Advertise | View Online Your trusted source for Cloud, AI and DevOps guidance with industry expert Chris Pietschmann! Phi-4: Microsoft's New Small Language Model Outperforms Giants in AI

Mapped | The Top Health Insurance Companies by State 🏥

Tuesday, December 24, 2024

In 13 US states, a single company dominates the health insurance market, holding at least half of the total market share. View Online | Subscribe | Download Our App Presented by: Global X ETFs Power