Web · Ebook
Playwright: Modern Browser Automation for Testing and Scraping
by Shriira Press
A comprehensive, self-contained guide to Playwright — the modern framework (from Microsoft) for driving real browsers through code. Like Selenium, it launches Chromium, Firefox, and WebKit, navigates pages, runs their JavaScript, clicks and types, and reads the rendered result — for two big jobs: automated end-to-end testing and scraping JavaScript-rendered pages. But Playwright was designed after Selenium, learning from its pain points: it auto-waits for elements (eliminating most flaky-test bugs), drives all major engines through one API, intercepts and mocks network traffic, and ships a first-class test runner, codegen, and trace viewer. This book teaches it end to end — the browser/context/page model, locators, actions and auto-waiting, web-first assertions, network interception, real-world page handling, scraping, the test runner, and debugging/CI — blending intuition, the concepts behind the framework, and runnable code.
Contents
- 1Preface
- 2Chapter 1 — What Is Playwright?
- 3Chapter 2 — How Playwright Works: Browser, Context, and Page
- 4Chapter 3 — Getting Started: Installation and Your First Script
- 5Chapter 4 — Locators: Finding Elements the Playwright Way
- 6Chapter 5 — Actions and Auto-Waiting
- 7Chapter 6 — Assertions and Web-First Waiting
- 8Chapter 7 — Navigation, Network, and Waiting for State
- 9Chapter 8 — Network Interception and Mocking
- 10Chapter 9 — Real-World Pages: Frames, Dialogs, Auth, and Downloads
- 11Chapter 10 — Scraping with Playwright
- 12Chapter 11 — The Playwright Test Runner
- 13Chapter 12 — Debugging, Tracing, and CI
- 14Chapter 13 — In Practice, the Ecosystem, and the Profession
- 15Appendix A — Glossary and Quick Reference
- 16Appendix B — Further Reading and Resources
