The other day, a friend messaged me, a bit stuck on a Playwright test: “I’m trying to add all 3 products to the cart, but only 2 are getting added, and then it crashes! 🤯” I couldn’t resist helping out and it turned into a fun little debugging adventure. Let me share how we cracked it! 🌟 The Scenario It was a practice website with exactly 3 products. My friend’s mission: 👉 Log in 👉 Add all 3 items to the cart 👉 Validate that everything worked smoothly. Sounds simple, right? But the page had a dynamic twist! 🐛 The Initial Problem Here’s what he was using at first: const addToCartButtons = page . locator ( 'button:has-text("Add to Cart")' ); for ( let i = 0 ; i < 3 ; i ++ ) { await addToCartButtons . nth ( i ). click (); } But… it would only add 2 items and then fail with a timeout error! Turns out, Playwright was trying to click a button that no longer existed after the page updated. 🔍 What Was Happening? When yo...