Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk6 min

How to Keep UI Tests Reliable as Your Website Changes

Reliable UI tests focus on user-visible behavior, deliberate locator contracts, controlled state, and failures that teams investigate rather than hide with retries.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

UI tests stay reliable when they check what users can see and do, use locators that represent deliberate product contracts, wait for observable outcomes, and control the data and browser state each test depends on. When the interface changes, investigate a failed test against the intended user behavior before changing its selector: the failure may reveal a real regression, or simply a locator that no longer matches the design.

Start with behavior users can observe

A test should describe a meaningful user task and verify its visible result. Prefer checks such as “a confirmation appears after saving” over checks about internal function names, data structures, or styling classes. Playwright’s guidance puts the principle plainly: “Automated tests should verify that the application code works for the end users, and avoid relying on implementation details such as things which users will not typically use, see, or even know about such as the name of a function, whether something is an array, or the CSS class of some element.” Playwright Best Practices

This does not mean every test must click through the entire application. Keep browser tests for behavior whose value depends on the browser and the integrated interface. Test isolated calculations and other lower-level logic closer to the code that owns them; browser tests require more setup and infrastructure. Selenium’s overview discusses that trade-off and recommends concise tests. Selenium: Overview of Test Automation

Write scenarios around a small user goal

A useful browser scenario prepares the data it needs, performs a short sequence of meaningful actions, and checks a visible outcome. For example: create or load a draft, enter a title, save it, and verify that the saved title is shown. Avoid making one test cover unrelated workflows; failures are easier to diagnose when the scenario has one clear purpose.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose locators as deliberate contracts

Use a locator that represents what the test intends to protect. Roles and accessible names are often a strong fit when the control’s meaning and wording are part of the user experience. Visible text is useful when the text itself matters. A dedicated test ID can be appropriate when copy may change independently of the behavior and the team agrees to maintain that test contract.

Avoid tying tests to CSS classes, generated identifiers, or long DOM paths merely because they are easy to select today. A styling refactor should not ordinarily break a behavior test. Conversely, if a button’s accessible name changes, a test using that name may correctly reveal a change that needs review rather than an obsolete selector.

When a locator fails after a redesign

  1. Check the failure output and current page to see what a user would encounter.
  2. Decide whether the expected user behavior or wording has changed intentionally.
  3. If behavior changed, update the assertion and related product expectations deliberately.
  4. If only implementation or presentation changed, choose a locator aligned with the same user-facing contract, or maintain an agreed test ID.
  5. Run the scenario independently and in the full suite to check for state or ordering dependencies.

Do not “fix” a failing test by weakening its assertion until it passes. First establish whether the product behavior is still correct.

Wait for state, not elapsed time

Browser actions can be delayed by rendering, network responses, animation, or application work. Fixed sleeps assume a particular speed: they waste time when the page is fast and can still be too short when it is slow. Prefer the framework’s actionability checks and assertions that wait for the expected state. Playwright documents both actionability waiting and retrying assertions in Writing tests.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For instance, wait for the success message to become visible after saving rather than pausing for an arbitrary interval and then checking. Use a network or application-state condition only when it is the actual contract under test; an internal request finishing does not always mean the user-visible result is ready.

Control state and isolate tests

A test that depends on another test having run first is fragile in parallel execution, after a retry, or when someone runs just one scenario locally. Each test should establish the state it needs and clean up or uniquely scope any data it creates. Use controlled staging data where practical, and make test accounts and records distinguishable so concurrent runs do not overwrite one another.

  • Do not rely on a prior test to log in, create a record, or set a preference.
  • Use dedicated test data or unique values for records created during a run.
  • Keep browser storage, cookies, and profiles predictable; ordinary browsing state should not silently affect a test.
  • Make cleanup safe to repeat, so a retry does not fail because a previous attempt partly completed.

Playwright’s best-practice guidance covers isolation and controlled data. Selenium’s Encouraged behaviors similarly discusses independent tests, state, and locator choices while noting that recommendations depend on context: “No one approach works for all situations.”

Keep browser coverage valuable and focused

Browser end-to-end tests are comparatively expensive to run and maintain. Use them to protect important integrated user journeys, not as the only way to test every edge case. A short scenario that catches a serious regression is generally more useful than a long test that traverses many unrelated pages and fails ambiguously.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose browser coverage according to the people and environments the site serves. Framework support differs and changes over time: Playwright documents Chromium, Firefox, and WebKit projects; Cypress lists Chrome-family browsers and Firefox, and marks WebKit support experimental on its Launching browsers page. Verify current support and the versions relevant to your audience when selecting a setup; neither framework is a universal answer.

Make failures diagnosable and retries honest

Keep enough failure evidence to answer what the browser displayed and what the test was waiting for. Depending on the framework and CI setup, useful artifacts can include a screenshot, trace, browser console output, or network details. A failed test should make it possible to distinguish an application regression from missing data, a timing assumption, or an environment problem.

A test that passes only on retry is still a flaky result to investigate, not proof that the suite is reliable. Playwright documents how retries classify tests that fail initially and pass on retry in its Retries guide. Track recurring flaky scenarios, find the underlying race or shared state, and fix it rather than treating retries as a substitute for diagnosis.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Make test maintenance part of product changes

When a feature or redesign changes user behavior, update its browser scenarios in the same change as the interface where possible. Review what the test promises, not just whether its selectors compile. Run the relevant test locally, then run the suite in CI often enough that failures are found near the change that caused them. Maintain browser versions and CI configuration as part of the test environment, especially when browser behavior is part of the requirement.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Identify the user-visible behavior the change is meant to preserve or alter.
  2. Update test data, expected outcomes, and locators to match that intended behavior.
  3. Run the focused scenario and inspect any failed evidence.
  4. Run the broader suite in CI to catch integration or isolation problems.
  5. Investigate every retry-pass or intermittent failure rather than silently accepting it.

Or skip the browser setup

For a visual capture of a page, ScreenshotNeo offers a website screenshot API and MCP server. A screenshot can help inspect appearance, but it does not replace interaction tests that verify what users can do.

One GET request can return an image or PDF. For example, this cURL request saves a WebP capture of a page:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo documentation for API options and setup. Cookie banners are accepted and removed before capture, along with supported newsletter popups and chat widgets; those steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. Sign up free for ScreenshotNeo.

Frequently Asked Questions

Should a UI test assert every detail visible on the page?

No. Assert the visible outcome that matters to the scenario; unrelated details make tests more sensitive to harmless interface changes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.