Marketing Playbook preview

UI Testing with Puppeteer

Implement end-to-end testing and browser automation using JavaScript and Node.js.

Write fail-safe automation tests, device emulation, and browser automation using Puppeteer’s API powered by Google

Look inside

What you will learn

  • Understand browser automation fundamentals
  • Explore end-to-end testing with Puppeteer and its best practices
  • Apply CSS Selectors and XPath expressions to web automation
  • Discover how you can leverage the power of web automation as a developer
  • Emulate different use cases of Puppeteer such as network speed tests and geolocation
  • Get to grips with techniques and best practices for web scraping and web content generation
Brandon Guidelines

“UI testing with Puppeteer has everything you need to get started with UI testing. It's the book the community was waiting for”

Rodrigo Díaz Concha, Microsoft Regional Director

Full Chapter Overview

Chapter 1, Getting started with Puppeteer

It will help you get started with Puppeteer by introducing you to the tool and getting you acquainted with the essentials to get started. You will also cover how to write async code in JavaScript.

Chapter 2, Automated Testing and Test runners

It covers end-to-end testing fundamentals and the difference between different types of tests. In the latter part of the chapter, we will cover creating and organizing a test project and getting started with test runners.

Chapter 3, Navigating through a website

This chapter allows you to start coding your tests. You will learn how to launch a browser, navigate to a page and make some assertions. Then you will see how to publish your tests to the cloud to be tested.

Chapter 4, Interacting with a page

It's about interaction. Once you get to a page, how do you test it? How do you simulate user interaction? This chapter takes you through the most common ways of interacting with a page. This chapter also covers some basic HTML concepts, so you can take advantage of all the tools Puppeteer provides.

Chapter 5, Waiting for elements and network calls

Learn how to wait for the different scenarios on the page you are testing—waiting for the page to load, and to be ready, waiting for a button to be enabled, waiting for an Ajax call to be completed. This chapter covers all the tools that puppeteer offers to accomplish these scenarios.

Chapter 6, Executing and Injecting JavaScript

Chapter 6 shows you one of the best features in Puppeteer: Injecting JavaScript code easily. In this chapter, we will leave the end-to-end testing world for a moment and dive into web-automation as a general-purpose tool.

Chapter 7, Generating Content with Puppeteer

It expands the usage of Puppeteer and shows you how we can create content using Puppeteer. We’ll start by learning how screenshots are created and how they can be used for regression tests. Then we will cover PDF generation, and finally, we will learn to create pages on the fly.

Chapter 8, Environments emulation

This chapter explains all the tools Puppeteer provides to emulate different scenarios. It will show you how to emulate mobile devices, different screen resolutions, various network speeds, geolocation, and even things like vision deficiency.

Chapter 9, Scraping tools

Chapter 9 demystifies web scraping - showing how it can be implemented for good purposes. You will learn how to create scrapers and run tasks in parallel using Puppeteer Cluster

Chapter 10, Evaluating and improving the performance of a website

This last chapter shows you how puppeteer can help developers to evaluate and improve the performance of their sites. We will see how all the metrics you can see inside dev tools can be extracted and analyzed using Puppeteer. This chapter also has a great introduction to Google Lighthouse and how to automate its reports and integrate them into your test.

Who Should Read This Book?

Quality Assurance professionals

If you are a quality assurance professional looking for a better and more modern tool to do your job, this is the book for you.

Web Developers

Web developers who want to learn how to use Puppeteer for generating content, scraping websites, and evaluating website performance will find this book useful.

Dario Photo

About the author

Dario Kondratiuk, Microsoft MVP

Dario Kondratiuk has been a web developer since 2001. He won the Microsoft MVP (most valuable professional) award in 2020 for his contributions to the developer’s community. Dario has been working with Puppeteer since the beta versions, back in 2017. He is the author of Puppeteer-Sharp, a Puppeteer port to .NET, and Playwright-Sharp, a Playwright port to .NET. He writes about web automation in his blog hardkoded.com, and he’s active on Stack Overflow.

Download the e-book today