Test Automation 101: Deciding What, When, and How to Automate
For UI automation: Selenium and Playwright are the two most common choices today, with Cypress also widely used for JavaScript-heavy frontends.
Automation isn't a productivity switch you flip on. Automating the wrong things, unstable features, one-off scenarios, UI still under active redesign creates a slow, flaky, high-maintenance suite that actively slows a team down more than manual testing ever did. The teams that get real value from automation are disciplined about what they automate, not just enthusiastic about automating.
This article covers the test automation pyramid, concrete criteria for deciding whether something is a good automation candidate, and an honest look at what shouldn't be automated yet.
The Test Automation Pyramid
The pyramid describes an ideal shape for a test suite: a large base of unit tests (many, fast, cheap, owned by developers), a smaller middle layer of API and service-level tests (fewer, still reasonably fast, testing business logic without UI overhead), and a small top layer of UI/end-to-end tests (fewest, slowest, and the most expensive to maintain).
When teams invert this heavy on UI automation, light on unit and API coverage the shape earns the nickname 'ice cream cone,' and it causes real pain: slow CI runs, flaky UI tests that fail for reasons unrelated to actual bugs, and a maintenance burden that eventually makes people stop trusting the suite's results altogether. The pyramid isn't dogma, but the underlying principle holds up well: push verification down to the cheapest, fastest layer capable of catching the bug.
What makes a good automation candidate
Stable requirements, automating a UI that's actively being redesigned means rewriting the automation as often as the feature changes, which erases most of the ROI. Repetitive execution, a flow that gets run on every build or every regression cycle earns its automation cost back quickly; a scenario tested once a year almost never does. Deterministic pass/fail automation needs a clear, checkable expected outcome; anything requiring subjective visual or usability judgment resists automation by nature. And genuinely high manual-execution cost or business value the login and checkout flow, not the rarely-visited settings page.
What not to automate - at least not yet
Exploratory and usability testing stay fundamentally human, because they require judgment automation doesn't have. One-off or rarely-run scenarios rarely justify the build cost. A UI still in active design iteration is a trap you'll rewrite the automation faster than it delivers value. And anything requiring subjective visual comparison without a mature visual-testing tool in place tends to produce automation that's technically 'passing' while missing the actual problem.
The broader automation ecosystem
For UI automation: Selenium and Playwright are the two most common choices today, with Cypress also widely used for JavaScript-heavy frontends. For API-level automation: REST Assured (Java) and Postman with its Newman CI runner are standard choices. Test runners like TestNG and JUnit (Java) or pytest (Python) provide the structure of annotations, assertions, data-driven execution that turns individual scripts into an organized suite. And none of it delivers ongoing value without CI/CD integration: hooking the suite into Jenkins or GitHub Actions so it runs automatically on every relevant build, rather than manually and occasionally.
One point worth being honest about early: automation code is still code, and it comes with the same ongoing maintenance cost as any other codebase a team owns. Budgeting time for that upkeep, not just the initial build, is what separates automation efforts that are still useful a year later from ones that quietly get abandoned once the person who wrote them moves on.
Real-World Example
A team building a service-booking app starts its automation effort with login and the core booking flow both stable, both run on literally every build, both painful to re-check manually every single time. They build this out with Selenium and TestNG.
At the same time, they deliberately leave the newly redesigned reviews-and-ratings screen manual, because the design is still actively changing sprint to sprint automating it now would mean rewriting locators and flows every couple of weeks for a feature that hasn't stabilized. Six months later, once that UI settles into its final form, they add it to the automation suite. That sequencing stable and high-value first, actively-changing UI deliberately deferred is a small decision that saves a meaningful amount of wasted rework over the life of the project.
Best Practices
- Start automation with the highest-value, most stable flows, not simply the easiest ones to script.
- Keep the pyramid shape in mind and push logic-heavy checks down to API or unit level wherever possible.
- Version-control automation code and hold it to the same review standards as production code.
- Integrate automated suites into CI so failures surface immediately, not a week later during manual review.
- Track and fix flaky or failing tests quickly a distrusted suite stops delivering value even if it's technically running.
Common Mistakes to Avoid
- Mistake: Trying to automate every test case regardless of stability or value
Fix: Apply concrete candidate criteria stability, repetition, deterministic outcome, business value before automating anything. - Mistake: Building heavy UI automation for a still-changing interface
Fix: Defer automation until the UI stabilizes; keep testing it manually in the meantime. - Mistake: No code review process for automation scripts
Fix: Treat automation code like production code reviews, standards, and consistent structure. - Mistake: Not integrating automation into CI
Fix: Wire the suite into the build pipeline so it runs on every relevant commit, not manually and occasionally. - Mistake: Ignoring flaky tests until the whole suite is distrusted
Fix: Quarantine and fix flaky tests immediately rather than letting failures become background noise.
Key Takeaways
- Automate for return on investment, not for the sake of having an automation suite.
- The test pyramid is a guide for where to invest effort, not just a description of UI test count.
- Good automation candidates are stable, repetitive, deterministic, and genuinely high-value.
- Automation without CI integration and ongoing maintenance discipline decays fast.
- Manual and exploratory testing stay essential even inside a mature, well-built automation setup.