Book Image

UI Testing with Puppeteer

By : Dario Kondratiuk
Book Image

UI Testing with Puppeteer

By: Dario Kondratiuk

Overview of this book

Puppeteer is an open source web automation library created by Google to perform tasks such as end-to-end testing, performance monitoring, and task automation with ease. Using real-world use cases, this book will take you on a pragmatic journey, helping you to learn Puppeteer and implement best practices to take your automation code to the next level! Starting with an introduction to headless browsers, this book will take you through the foundations of browser automation, showing you how far you can get using Puppeteer to automate Google Chrome and Mozilla Firefox. You’ll then learn the basics of end-to-end testing and understand how to create reliable tests. You’ll also get to grips with finding elements using CSS selectors and XPath expressions. As you progress through the chapters, the focus shifts to more advanced browser automation topics such as executing JavaScript code inside the browser. You’ll learn various use cases of Puppeteer, such as mobile devices or network speed testing, gauging your site’s performance, and using Puppeteer as a web scraping tool. By the end of this UI testing book, you’ll have learned how to make the most of Puppeteer’s API and be able to apply it in your real-world projects.
Table of Contents (12 chapters)

The headless recorder

The headless recorder is a Chrome extension developed by Checkly (https://www.checklyhq.com/). This extension will record the actions you perform on a page and generate Puppeteer code based on those actions. I think it's a great tool to get a first draft of a Puppeteer test, and from there, start working on the final code.

You can download this extension by going to the Chrome Web Store (https://chrome.google.com/webstore) and searching for Headless Recorder:

Headless Recorder

Once installed, you will find a recorder icon at the top right of your browser. From there, you will have the record button, which will start to capture all the actions you perform on a page:

Record option

Once you finish performing your test actions, you click stop, and you'll get the code almost ready to be used:

Headless Recorder result

I say almost ready because the recorder can't guess your...