In brief
AI in test automation works best as a fast author of drafts: it proposes test cases from requirements, writes test code, fixes locators after a UI change and groups failures from the nightly run. Every one of these outputs needs review, because the model does not know the business intent and can lock a bug in as the expected result. A self-healing fix should be a proposed change for approval, not a silent patch in CI. Measure the effect instead of assuming it.
Where AI helps and where it hurts
AI tools now show up at every stage of testing work. Their value varies a lot.
| Use | What you gain | What to watch for |
|---|---|---|
| test cases from requirements | a fast first draft, boundary values, negative cases | the model repeats the errors and gaps in the requirement |
| automated test code | less repetitive code to write | brittle locators, weak assertions, duplicates |
| self-healing locators | fewer red runs after a UI change | "fixing" a real application bug |
| failure analysis | failures grouped by cause | a wrong cause stated with confidence |
| test data | realistic records without personal data | data that breaks the system's rules |
What they share: AI cuts preparation time but does not remove responsibility for judgment. The tester stops writing from scratch and starts reviewing, which is faster only when the review is thorough.
Generating test cases from requirements
A language model is good at breaking a requirement into cases. From the rule "a 5% discount for orders of 1,000 PLN or more" it will propose 999.99 PLN, 1,000 PLN and 1,000.01 PLN, an order with a correction, a foreign currency and a cancelled order. That is a good starting point, often more complete than a person's first draft.
The problem lies elsewhere. The model does not know what the requirement is missing. It will not ask whether 1,000 PLN is net or gross, or what happens to the discount when part of the goods is returned. Questions about gaps are asked by a tester who knows the process. The second risk is the test oracle: when the model derives the expected result from the code rather than the requirement, the test confirms what the code does, bugs included.
A practical order of work:
- The tester reads the requirement and writes down questions for the analyst.
- The model proposes cases based on the requirement, not the code.
- The tester removes duplicates, adds cases from process knowledge and sets the expected results.
- The cases go through review like any other artifact, and priority follows risk, as in risk-based testing.
Self-healing tests
A UI test often fails not because the application is broken but because a button ID or the page layout changed. Self-healing is meant to remove that problem. It works in two ways. Older tools remember several attributes of an element (text, role, position, attributes) and, when the main locator fails, look for the element by the others. Newer ones use a language model that runs the test, inspects the page and edits the code. Playwright, for example, ships a set of test agents: a planner that explores the application and writes a test plan, a generator that turns the plan into code, and a healer that runs the tests and repairs the failing ones.
The biggest risk is healing a real bug. If the "Approve transfer" button disappeared after a change and the test "heals itself" by clicking another button, the team gets a green result for a broken feature. So the rules are simple:
- a fix in CI is never silent: it goes into the report and into the test code as a change to approve,
- changing an assertion is not a locator fix; the agent should not change expected results,
- better locators reduce the need for healing: roles and accessible labels instead of CSS classes, as the Playwright documentation recommends.
Failure analysis and flaky tests
After a nightly run of several hundred end-to-end tests, the team loses the morning going through red results. AI is good at grouping failures: the same messages, the same step, the same service in the trace. Thirty red tests become three causes. That is a real saving.
It gets worse when the model names the cause. It sounds convincing even when it is guessing. Treat grouping as a hint and confirm the cause in the logs. Result history also helps separate real bugs from tests that fail at random, as described in the article on flaky tests.
Data, security and measuring the effect
Three rules before a team starts using AI in testing every day:
- Data. Production data and code the company does not want to disclose are not sent to an external model. When the data includes personal data, the GDPR applies, as covered in Test data and the GDPR. A model running on the company's own server is often the answer.
- Repeatability. AI works while tests are written and repaired, but the CI run itself stays deterministic. A test that asks a model for a decision on every run gives different results for the same code.
- Measurement. Compare before and after: time to prepare tests for a user story, the number of red runs without an application bug, time spent analyzing failures. The quality of generated tests can be checked with mutation testing: it shows whether tests written by a model detect anything at all.
How to start
- Pick one area with a lot of repetitive work, for example API tests for new endpoints or fixing locators in UI regression.
- Agree on review rules: who approves generated cases and changes to tests.
- Measure time and the number of corrections after review for two or three sprints.
- Extend to further areas only when the numbers show a gain.
In test automation the rule is the same with or without AI: the framework and the tests stay in the client's repository, and a person decides what to test and which result is correct. Testing AI systems themselves is covered in Testing AI systems.
Questions and answers
Will AI replace testers?
Not in the way people say. AI takes over writing repetitive code and first drafts of test cases. What remains is work a model does not do well: asking about gaps in requirements, assessing risk, exploratory testing and deciding whether a result is correct. The tester's role shifts toward reviewing and designing tests.
Are self-healing tests safe in a banking system?
Yes, if a fix is a proposal for approval rather than an automatic change in CI. Every locator change should be visible in the report and in the history of the test code. The agent should not change assertions or expected results. With these rules, self-healing saves time and an auditor can see who approved a change and when.
What data can you give a model when generating tests?
Requirements, test code and anonymized or synthetic test data. Production data containing personal data should not be sent to a model outside the company. When a team needs to work with real data, a model running on the company's server or in a data center in Poland is the better choice, with a data processing agreement in place.
How much time does AI save in test automation?
It depends on the area and on the quality of the review, so the only honest answer comes from measuring it. The biggest gains usually show up in repetitive test code and in grouping failures. The smallest are in complex end-to-end tests, where reviewing generated code takes almost as long as writing it from scratch.