Urgent.News

What's breaking now, across thousands of outlets.

Tech

The Second Browser Tab Is Where Good Tests Go to Die

The sign-in test passes locally. Then you run it in CI and the browser sits on a blank tab until the job times out. The application is fine. The identity provider is fine. The browser opened another window, and the automation is still trying to click a button in the first one. Welcome to one of the less glamorous parts of browser automation: keeping track of which browser context you're actually…

Many automated tests fail because they do not properly manage browser contexts and session states. A common issue is that a test opens a popup window during authentication, but the test still clicks buttons in the main browser window. This can cause tests to appear to succeed when in reality the authentication never completes. The source material emphasizes that tests should verify the correct window is active and that the application state changes as expected after authentication, rather than just checking for the disappearance of a popup.

The guide to cross-origin popups and OAuth returns stresses following window lifecycle events to avoid broken tests that look successful. Another key issue is test state leakage, where a test leaves behind data from a previous run, causing subsequent runs to behave differently and be labeled as flaky. The source recommends defining the desired starting state for each test, such as whether it's a first-time login or a returning user, and properly resetting any test data created.

The guide concludes that understanding the sequence of events and capturing evidence of what went wrong is more valuable than just a simple pass/fail result.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Wednesday 14 October →