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)

Introduction to web scraping

The best way to introduce a new concept is by giving a few concrete and straightforward definitions. Let's begin by defining data scraping. According to Wikipedia (https://www.hardkoded.com/ui-testing-with-puppeteer/data-scraping), "Data scraping is a technique in which a computer program extracts data from human-readable output coming from another program." Any information coming out from a computer can be extracted and processed. The first scrapers were called "screen scrapers." A screen scraper is something as simple as an application that can capture the screen. Then, by running Optical Character Recognition (OCR), it extracts the text from that image for further processing.

Web scraping takes this idea to the next level. Web scraping is a technique used to extract data from one or multiple websites using a piece of software.

You might be wondering: Is that even legal? Amazon is a public site. I can freely navigate through...