Software Testing

Intermediate path · lesson 12 of 19

IntermediateAutomation5 min readPublished November 12, 2026

UI testing without becoming a click-testing robot

UI testing goes wrong in two ways: people mindlessly clicking through scripts, and automated suites that break whenever a button moves. Here's how to test the UI thoughtfully, manually and automatically.

On this page

Key takeaways

  • The UI is where users meet the product. Test there what only the UI can show: real user journeys, layout, feedback, accessibility. Push business rules down to faster layers.
  • In automation, find elements the way users do, by role, label and visible text, and wait for conditions, not fixed times. That alone removes much of the fragility.
  • In manual testing, scripts are a starting point. Observe, question and explore, because that's what a human adds.

Where this picks up

The test pyramid says to keep UI tests few. But "few" doesn't mean "unimportant". The UI is the only layer that shows what users actually experience. The question is how to test it well.

Two kinds of click-testing robot

The human robot. A tester follows a 40-step script, ticks "pass" and moves on, without noticing the misaligned price, the confusing error or the three-second freeze. The script passed; the experience didn't.

The automated robot. A suite of UI tests that clicks through every screen to check every rule. It takes hours, breaks when a designer renames a CSS class and is re-run "until it's green".

Both have the same problem: activity without thinking.

What belongs in UI tests

Test in the UITest lower down
A customer can complete a purchase end to endEvery combination of discount rules
Errors are shown clearly next to the right fieldEvery validation rule for every field
The page works on a phone screenPrice calculation logic
Keyboard and screen reader can complete the journeyPermission rules for every role
Loading and empty states make senseAPI error codes

A good rule: if the check is about what the user sees or does, it belongs in the UI. If it's about what the system calculates or decides, it belongs in unit or API tests.

Automated UI tests that don't break every week

Find elements the way users do

Fragile locators are the main reason UI tests break:

FragileRobust
div.sc-3xk9 > div:nth-child(3) > buttongetByRole('button', { name: 'Pay now' })
#input_1742getByLabel('Email address')
XPath through the whole pagegetByText('Order confirmed')

Modern tools like Playwright and the Testing Library family recommend locators based on role, label and visible text. They survive redesigns, and they also check accessibility: if a test can't find a button by its accessible name, a screen reader user can't either.

Testing Library's guiding principle sums it up: the more your tests resemble the way your software is used, the more confidence they can give you.

Wait for conditions, not for time

sleep(5000) is either too long (a slow suite) or too short (a flaky test). Instead, wait for what you need: the button to be enabled, the text to appear, the request to finish. Most modern frameworks wait automatically for elements to be ready, and their assertions retry until a timeout.

Keep tests independent and fast

  • Set up through the API, not the UI. Create the user and the order with API calls, then test only the screen you care about.
  • Log in once and reuse the session, instead of typing the password in every test.
  • Each test cleans up, or uses its own data, so tests can run in any order and in parallel.

Organise the code

Group the details of each screen in one place, for example with page objects: a CheckoutPage with methods like payWithCard(). When the screen changes, you update one file, not fifty tests.

Check the look, carefully

Visual regression testing compares screenshots with approved versions and flags differences. It catches layout bugs that functional assertions miss. Use it on stable, important screens, and hide dynamic content like dates, or every run will show differences.

Manual UI testing that isn't robotic

Scripts tell you where to go. Your eyes and judgement do the testing:

  • Observe everything on the way: alignment, wording, loading times, what happens on hover and focus.
  • Vary the path: back button, refresh, a second tab, a slow network, a small screen, zoom at 200%.
  • Use the keyboard only for at least one journey.
  • Ask "would a real user understand this?" at every error message.
  • Note anything odd, even when the step "passed".
Real-world exampleThe redesign that broke 300 tests

An e-commerce team had 300 automated UI tests, written with CSS selectors copied from the browser's developer tools. A designer moved the checkout to a new component library. The pages looked almost the same, but 270 tests failed, all because of locators.

Fixing them took two testers more than a week. While they did, the team released without UI test coverage, and a real bug slipped through: the "Pay now" button was missing on small phones.

They rewrote the locators using roles and labels and moved most rule checks to API tests. The UI suite shrank to 60 tests. The next redesign broke four.

Lesson: locators tied to how the page is built break when it's rebuilt. Locators tied to what users see survive.

Do

Write UI tests as short user journeys with clear names: "guest can buy a product with a card". Set up data through the API; assert on what the user sees.

Don't

Automate a manual test script click by click, including every field check. You get a slow, fragile copy of a test that belonged lower in the pyramid.

Check yourself

A UI test clicks 'Search', waits 5 seconds with a fixed sleep, then checks the results. It fails about once in ten runs. What's wrong, and how would you fix it?

Show answer

The fixed wait is the problem: sometimes results take longer than 5 seconds. Replace it with a condition: wait until the results list is visible, or until the search request completes, using the framework's built-in waiting. The test becomes both faster on average and stable.