How to get started with automated web testing
Updated:
Start with one important scenario that the team checks manually on a regular basis. A small pilot will show whether you can trust the result, how much maintenance it takes and where automation helps. It should produce a working test, a useful report and a decision about what to do next.
What to settle before writing the first script
A team may wait for complete documentation or spare capacity while repeating the same checks before every release. You can start with less documentation if you know the expected result and have the conditions needed for safe testing. A recording of clicks cannot replace a missing rule.
The opposite risk is writing many simple tests without a clear goal. Maintenance grows, but the team still checks its most important journey manually. First agree on the specific check the pilot should take over and when you need its result.
Choose one journey, or a small scope of one to three related journeys. Which scenarios to automate first covers selection in detail. Here, the aim is to take the selected scenario through to everyday use by the team.
Write down the goal and expectation
A goal might be to find out, before release, whether a delivery address is saved correctly when the customer profile changes. “Introduce automation” is too broad. A specific goal defines what the test checks and how you will evaluate the pilot.
Confirm the preconditions, steps and result with the product owner. If saving an address requires an additional confirmation, the test must include that step. Agree on the cases you will leave outside the initial scope, such as all countries, mobile screen sizes or address changes during an order already in progress.
Before automating, perform the same check manually and record the time spent preparing data, checking the result and evaluating the outcome. Later, you will compare the same work under similar conditions. Do not compare a pilot in one browser with a manual check of the entire website.
Illustrative pilot: saving a delivery address
The following example is a proposed procedure, not a result achieved for a particular client. It assumes a profile that allows delivery address changes and a separate test account.
| Part of the scenario | What to agree |
|---|---|
| Preconditions | A signed-in test customer, a known original address and an available form |
| Input | A new valid address that differs from the original |
| Action | Complete the form and save the change |
| Result | Reopening the profile displays exactly the new details |
| Completion | Remove created data or restore the original state as agreed |
A success message after clicking does not prove that the change was saved. The test therefore reloads the profile and compares specific values. If the application holds the data only in the browser, add verification through an approved API or a new session that reads the state from the server. Choose the check according to how the application actually retrieves data.
This pilot checks a user outcome. It follows Playwright’s recommendation to test user-visible behaviour rather than depending on the internal structure of the code.
Prepare the environment and your own data
Agree on the test environment URL, application version and how to obtain a test account. Verify that the test run will not send a real shipment or affect customer data. If an address change triggers a notification, use a controlled mailbox or an agreed substitute for sending it.
Each run needs a known original address and a new address. Use a dedicated account or isolated data that another test or person will not modify at the same time. Setup must confirm its preconditions. If account creation or sign-in fails, that is a setup failure rather than evidence of an address-saving defect.
Browser isolation in Playwright separates cookies and storage between tests. It does not, by itself, separate accounts and records on the server. You need to handle those separately. The authentication documentation also warns about shared-account conflicts and sensitive information in saved authentication state.
Keep credentials in environment settings or a secrets store. Do not commit authentication state to the repository. Agree on cleanup after failed runs too, so the next attempt does not start with an unknown address. How to prepare a website for automation covers the broader preparation.
Build a test a colleague can run
Choose a tool according to the application, existing setup and the team’s skills. If you already have a maintained test suite, check whether the pilot can use its structure. For a new setup, try writing, running and debugging the selected scenario. A demonstration of successful clicks is not enough.
Separate the test into setup, user actions, result checks and cleanup. You do not need a large library of helper functions immediately. Names should explain the intent, for example, “a customer saves a new delivery address”.
Find elements by their label, role and name, or an agreed test identifier. Playwright recommends locators based on user-facing attributes. A long path through nested HTML elements ties the test to the page layout and may need updating when the design changes.
Wait for a specific result condition within a time limit. Playwright’s web assertions, the checks that compare actual and expected results, keep testing the condition. A fixed pause may be too short in a slower environment and unnecessarily delay a run in a faster one.
Document the command to run the test, required settings and data preparation. Ask a colleague to run it from a clean state without your manual help. This reveals hidden dependencies on local files, an open browser or an account you prepared only once.
Verify that the test detects an incorrect result
A green run shows that the written expectations were met. You also need to know whether the check reacts when the rule is broken.
In an isolated test version, prepare a case where the form reports success but does not save the new address. The check of the reloaded details should fail. Verify that the report identifies the address mismatch and that the test did not fail earlier at sign-in. Then remove the controlled defect and run the test again.
If you cannot safely prepare that change, temporarily set a deliberately incorrect expected value. This verifies that the specific check runs, but it is weaker evidence than an actual failure to save the address. Neither attempt establishes complete coverage of every profile defect.
Move the pilot into CI and assign ownership
CI means running checks automatically when code changes. The pilot can also run after deployment to a test environment, on a schedule or on demand. Choose the point when its result will help you make a decision about a specific change.
Prepare packages, the browser and system dependencies in CI. The Playwright CI documentation provides an example. Also check application availability, credentials and prepared data. The report must identify the version and environment actually tested, so a result from an old deployment is not mistaken for verification of a new change.
Retain the report when a test fails and verify that a colleague can open it. Decide who maintains the test, who investigates a red result and how new expectations are approved when the product changes. Agree on release-blocking rules according to the pilot’s reliability and the scenario’s impact.
A failure must support a clear diagnosis
The report should show the step, expected result and actual state. Distinguish an application defect, a test defect and an environment setup failure. For an address that was not saved, it helps to know whether the request was sent, the server rejected it or the profile displayed the original details after reloading.
A Playwright trace records the sequence of events, page snapshots and network requests. The retain-on-failure setting keeps a failed test’s trace even without retries. A trace may contain sensitive data, so define who can access it and how long it is retained.
If you enable retries for failed tests, track success on a later attempt separately. Playwright classifies that result as flaky. A retry provides another attempt. It does not remove the cause of instability.
Measure the team’s work and decide whether to continue
Choose a period that includes normal runs and relevant application changes. Do not rely solely on one green run. Record actual observations rather than estimated savings percentages.
| Measurement | What to record |
|---|---|
| Manual check | Preparation, execution and evaluation of the same scenario |
| Automated run | Time from starting the run to an available result, and time spent operating it |
| Diagnosis | Time spent identifying the cause of a failure and unnecessary reruns |
| Maintenance | Changes to data, locators, expectations and dependencies |
| Reliability | First-attempt failures, retry results and confirmed defects |
Machine execution time is not human working time. Record initial setup and training, ongoing maintenance and operating costs separately. ISTQB CTFL v4.0.1, section 6.2 identifies the benefits and the risk of underestimating this work.
Continue when the test checks the agreed result, detects the prepared defect, runs from a clean state and the team can handle failures. Costs and feedback speed must match your goal. There is no universal run count or guaranteed saving that establishes this.
If the pilot needs constant manual intervention, adjust the data, conditions or test design first. Add further scenarios after resolving the cause. Manual checks may be more suitable for a one-off or frequently changing feature, as discussed in when automation pays off.
Automation does not replace exploratory testing, usability assessment or conversations with users. The pilot should deliver a repeatable check of a specific outcome. The team’s quality work still needs to address the remaining questions.