How to test non-deterministic user flows with Playwright



AI Summary

This video tutorial from Checkly demonstrates how to handle non-deterministic user flows in end-to-end testing using Playwright. It focuses on challenges such as cookie banners or promotional popups that may appear randomly during tests, causing flakiness. The presenter uses a sample app with a sign-in button and a modal that sometimes appears asking users if they want to receive a surprise. They explain how to write Playwright tests that conditionally handle these popups by using JavaScript async/await and try/catch syntax to gracefully handle optional UI elements without failing the test. The video also covers useful tips such as using Playwright’s repeat-each flag to detect flaky tests, and the Playwright trace viewer to debug failures. The approach ensures tests remain stable and reliable even when UI interruptions are unpredictable.