UI Testing with Puppeteer: Implement end-to-end testing and browser automation using JavaScript and Node.js
Book information
Description
Write fail-safe automation tests, device emulation, and browser automation using Puppeteer's Google-powered API Key FeaturesGet up and running with Puppeteer and discover best practices for automation testingAutomate your modern web applications using Jest and Mocha with PuppeteerGenerate screenshots using Puppeteer and find out how they can be used for UI regression testsBook Description 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. What you will learnUnderstand browser automation fundamentalsExplore end-to-end testing with Puppeteer and its best practicesApply CSS Selectors and XPath expressions to web automationDiscover how you can leverage the power of web automation as a developerEmulate different use cases of Puppeteer such as network speed tests and geolocationGet to grips with techniques and best practices for web scraping and web content generationWho this book is for The book is for QA engineers, testing professionals, and frontend web developers alike who want to perform end-to-end testing using Google's developer tools. Web developers who want to learn how to use Puppeteer for generating content, scraping websites, and evaluating website performance will also find this book useful. Although knowledge of Node.js isn't necessary, basic JavaScript knowledge will assist with understanding the concepts covered. Table of ContentsGetting started with PuppeteerAutomated Testing and Test runnersNavigating through a websiteInteracting with a pageWaiting for elements and network callsExecuting and Injecting JavaScriptGenerating Content with PuppeteerEnvironments emulationScraping toolsEvaluating and Improving the Performance of a Website Cover Title page Copyright and Credits Dedicated Contributors Table of Contents Preface Chapter 1: Getting started with Puppeteer What is browser automation? Selenium and Puppeteer Introducing Headless browsers Available headless browsers The Chromium DevTools Protocol Introducing Puppeteer The Puppeteer object model Puppeteer use cases Task Automation Web Scraping Content generation End-to-end testing Setting up the environment Node.js Visual Studio Code Our first Puppeteer code Installing Puppeteer Hello world in Puppeteer Asynchronous programming in JavaScript Promise.all Promise.race Fulfilling our own promises Summary Chapter 2: Automated Testing and Test runners Technical requirements Introduction to Automated Testing Unit tests Service tests End-to-end tests Test runner features Available test runners Creating our first test project Organizing our code Introducing the Page Object Model Summary Chapter 3: Navigating through a website Technical requirements Introducing the tests sites for this chapter Creating a Puppeteer browser Using the Puppeteer.launch function Headless The user data directory Executable Path Default Viewport Product Browser Arguments Mobile options Options in practice Navigating through a site Timeouts waitUntil Referrer Using the response object Getting the response URL Getting the response status code Introduction to continuous integration Summary Chapter 4: Interacting with a page Technical requirements Introduction to HTML, the DOM, and CSS HTML The DOM CSS Selectors Finding elements Finding elements using XPath Interacting with Elements Typing on input elements Clicking on elements Selecting options in drop-down lists Keyboard and Mouse emulation Debugging tests with Visual Studio Code Summary Chapter 5: Waiting for elements and network calls Technical requirements Waiting for the page to load Waiting for elements Await a wait function Waiting for network calls Arrange, Act, Await Fire and forget Promise.all Waiting for page events The close event The popup event Target created event The console event The dialog event The headless recorder Summary Chapter 6: Executing and Injecting JavaScript Technical requirements Executing JavaScript code Variable scopes in JavaScript Manipulating handles with JavaScript code Getting information from the elements Acting on elements Enforcing server rules Finding elements using JavaScript Waiting for functions Exposing local functions Running our checks with Checkly Summary Chapter 7: Generating Content with Puppeteer Technical requirements Taking screenshots Using screenshots for regression tests Generate PDF files Creating HTML content Summary Chapter 8: Environments emulation Technical requirements Understanding the browser's market share The browser's popularity over the years Operative Systems market share Screen resolution distribution Emulating mobile devices The Viewport Pixel ratio The touchscreen The user agent Emulating mobile devices with Puppeteer Emulating network conditions Emulating localization Emulating geolocation Emulating time zones Emulating languages Other emulations Summary Chapter 9: Scraping tools Technical requirements Introduction to web scraping Does the site allow scrapers? Creating scrapers Running scrapers in parallel How to avoid being detected as a bot Dealing with authorization Summary Chapter 10: Evaluating and Improving the Performance of a Website Technical requirements The Issue of Performance Getting started with Google Lighthouse As part of Chrome DevTools Using PageSpeed Insights Using the command line Using the node module The performance category Using Lighthouse for testing Tracing Pages Analyzing code coverage Summary Why subscribe? About Packt Other Books You May Enjoy Index
Similar books
UI Testing with Puppeteer: Implement end-to-end testing and browser automation using JavaScript and Node.js
MOBI
UI Testing with Puppeteer: Implement end-to-end testing and browser automation using JavaScript and Node.js
2021 · EPUB
MySQL® Notes for Professionals book
2018 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF
Session C11: Ancient Cultural Landscapes in South Europe – their Ecological Setting and Evolution, Session C22: Gardeners from South America, Session S04: Agro-Pastoralism and Early Metallurgy Sessions, Session WS29: The Idea of Enclosure in Recent Iberian Prehistory, Session C88: Rhytmes et causalites des dynamiques de l'anthropisation en Europe entre 6500 ET 500 BC: Hypotheses socio-culturelles et/ou climatiques: Proceedings of the XV UISPP World Congress (Lisbon 4-9 September 2006) / Actes du XV Congrès Mondial (Lisbonne 4-9 Septembre 2006) Vol.36
2010 · PDF
THE BRITISH ARMY IN INDIA: ITS PRESERVATION BY AN APPROPRIATE CLOTHING, HOUSING, LOCATING, RECREATIVE EMPLOYMENT, AND HOPEFUL ENCOURAGEMENT OF THE TROOPS. with AN APPENDIX ON INDIA : THE CLIMATE OP ITS HILLS ; THE DEVELOPMENT OF ITS RESODRCBS, INDUSTRY, AND ARTS ; THE ADMINISTRATION OF JUSTICE ; THE BLACK ACT ; THE PROGRESS OF CHRISTIANITY ; THE TRAFFIC IN OPIUM ; THE VALUE OF INDIA ; PERMANENT CAUSES OF DISAFFECTION, AND OF THE RECENT REBELLION ; THE TRADITIONARY POLICY; MISGOVERNMENT BY NATIVE RULERS ; ANNEXATIONS OF THEIR TERRITORY, ETC.
1858 · PDF
Idries Shah 27 Books Collection : A Perfumed Scorpion, A Veiled Gazelle, Caravan of Dreams, Darkest England, Destination Mecca, Evenings with Idries Shah, Knowing How to Know, Learning How to Learn, Letters and Lectures of Idries Shah, Neglected aspects of Sufi study, Observations, Oriental Magic, Reflections, Seeker after Truth, Special Illumination, Special Problems in the study of Sufi ideas, Sufi thought and action, Tales of the Dervishes, The Dermis Probe, The Elephant in the Dark, The Englishman Handbook, Idries Shah Antology, The Magic Monastery, The natives are restless, wisdom of the Idiots PDF.
2022 · PDF