How to detect broken links with Playwright Test
AI Summary
This video from Playwright Tips explains how to detect broken links on web pages using Playwright and Checkly. It starts by introducing a test case that navigates to a local page with various link scenarios, including empty links, invalid domains, mailto links, 404 pages, and valid links. The presenter demonstrates extracting all link URLs from the page, filtering out duplicates and mailto links, and normalizing relative URLs to absolute URLs. The test then performs HTTP requests to each URL and asserts that they return a successful status code, using soft assertions to continue testing even when broken links are found. The video concludes by showing how this test can be run against real websites and integrated into CI/CD pipelines with synthetic monitoring, highlighting the benefits of scheduled broken link checking in production environments. The source code is available on GitHub, and the presenter encourages questions and comments for follow-ups.