Skip to main content

Back to all FAQs

How to add assertions to UI tests?

Assertions are the checks that turn a recorded flow into a real test. After each important action, verify something observable: text on screen, URL, element visibility, button state, or a success message. Without assertions, a test only proves the browser can click through - not that the app behaved correctly. Prefer assertions on outcomes users care about, not implementation details. Assert that checkout shows an order confirmation, not that a specific CSS class exists unless that class is the contract engineering guarantees. Combine a small number of strong checks per step rather than dozens of fragile ones. When a test fails, the assertion message should say what was expected. Update assertions when product copy or layout changes on purpose. Pair UI assertions with API or database checks when the visible UI is not enough to confirm backend state.

More testing & automation FAQs