Test Automation Best Practices
This guide is designed for users who are already familiar with UMAI and want to build reliable, scalable, and maintainable automated test suites. Rather than explaining basic functionality, it focuses on the best practices that help teams create consistent tests, maximize reuse through Action Groups and variables, and reduce long-term maintenance as applications evolve.
Quick-reference checklist
A quick checklist of best practices to help create a better UMAI experience. For further details, go to the sections below.
- Naming & Organizing Your Tests
- Test name clearly states what it checks and what passing looks like, following the format
TEST-ID - Scenario(see section 1 for the full naming convention and examples). - Description explains why the test matters, not just what it does.
- Tags follow the team's agreed tag vocabulary (see section 1 for tag examples).
- Tests and Action Groups are organized in the agreed folder structure.
- Test name clearly states what it checks and what passing looks like, following the format
- Action Groups & Variables
- Actions are grouped into an Action Group where they're reused, or where doing so meaningfully improves readability of a long or complex test.
- Action Groups use parameters instead of hardcoded values (see section 4 for variable types).
- Values that are reused or subject to change are stored as Global/Environment variables rather than typed directly into tests.
- If data-driven, the CSV/XLS/XLSX file has been reviewed and all variable bindings confirmed correct.
- Locators
- Identifiers are stable and specific, following the priority order in section 5.
- All locators and images generated by the Recorder are reviewed and verified.
- An element image is added wherever possible as a locator fallback.
- Waits & Timing
- Waits are used to synchronize browser actions with the actual state of the page.
- Condition-based waits (Wait Until Visible or Wait Until Not Visible) are preferred over fixed delays so tests remain reliable across different load times and environments.
- Timeout values match the expected load behavior of the specific page or action.
- Action-level overrides are used for individual exceptions, environment defaults for consistent environment-specific behavior, and global defaults only when the same timeout is appropriate everywhere.
- Recording Quality
- Recordings are short and focused on one logical flow.
- After recording, hardcoded values, identifiers, and actions have been reviewed and verified.
- Test Independence & Verification
- The test executes independently, in any order, with no hidden dependency on another test.
- Verify actions confirm expected application state at key points, either before or after critical actions.
- The test has been executed individually and passes before being added to a shared tagged run set.
- Execution & Scheduling
- Test state is set to Ready only after review is complete.
- Runs are named clearly by purpose (e.g.
Regression - Prerelease UMAI v2.4). - Parallel execution is used only for independent tests, i.e. tests that already satisfy the independence check in section 8. Tests sharing accounts or data don't qualify as independent.
- For business-critical flows, cross-browser coverage is considered and scheduled.
- Fixing Failures
- Before touching a failing test, the execution report was checked to confirm which action failed and why.
- The test was moved to Repair, fixed, then moved to Revalidate and run end-to-end before returning to Ready.
- Each fix or update is documented with a short description of what changed and why.
- Housekeeping
- Scheduled runs are reviewed periodically.
- Outdated tags, environments, or retired tests are removed.
1. Naming & Organizing Your Tests
Naming convention
Use a consistent naming pattern for every test so that any team member can understand and trace it.
Example:
Tags and folders
- Use folders to organize tests by their primary structure, such as feature, page, or workflow. Examples include Login, Billing, or Checkout.
- Use tags to provide metadata for searching, filtering, and creating flexible test sets across folders, such as Smoke, Regression, Critical, or Login.
- Example: a test inside the
Checkoutfolder might carry the tagsSmoke,Regression, andCriticalso it's included in a quick Smoke run, a full Regression run, and any Critical-path report, without living in three different folders.
Agree on a shared tag vocabulary as a team before tagging starts, so Critical means the same thing to everyone and doesn't compete with ad hoc tags like important or p1.
2. Creating and Generating Actions Using the Recorder
The Recorder can be started in the following ways:
-
At test creation, using the Record Actions in Interactive Browser button:
-
Between actions, once an Interactive Browser session has been started:
Plan reuse before you record
- Check whether Action Groups already cover any part of the flow, such as login, navigation, form submission, or date selection. Reuse them rather than re-recording.
- Identify actions that will repeat across multiple test cases for this feature, and plan to build those as Action Groups from the start.
Recorder
- Map out the scenarios you need to cover before using the Recorder.
- Keep recordings short and focused on one logical flow.
- Add Verify actions before or after critical actions to confirm the expected application state.
- When recording additional actions, run the test case to the required point first rather than chaining recording blocks directly. This ensures that the application is in the expected state.
3. Creating and Reusing Action Groups
An Action Group is a set of actions that can be grouped and reused in other tests. Any variables used turn into parameters. To create an Action Group, select the actions, right-click, and choose to create an Action Group:
Just like a test case, an Action Group has a title and a description (see section 1). The Action Groups that have been built are listed in the left-hand menu of the Workbench.
When to build an Action Group
- Build an Action Group when actions are reused across tests, or when grouping a sequence of actions under a clear name would make a long or complex test significantly easier to read and maintain.
- Before creating a new Action Group, check whether one already exists.
How to keep them maintainable
- Keep each Action Group focused on one specific task: "Log in", "Select date range", "Submit form" and so on.
- Use variables instead of hardcoded values to make Action Groups reusable across scenarios.
- Before modifying a widely used Action Group, check its dependencies and retest affected cases.
- Organize Action Groups using a common folder with subfolders for similar or related Action Groups.
- Use tags to categorize and filter Action Groups based on requirements, functionality, or other relevant criteria.
4. Use Variables for Better Flexibility
Use variables for values that need to be reused across tests, such as usernames, URLs, or passwords. This makes it easier to manage and update these values from one place instead of entering them directly in each test.
A simple way to think about the common variable types:
| Type | Use it for | Example |
|---|---|---|
| Test variable | A value only needed in one specific test | A username used only in that one test |
| Global variable | A value reused across many tests | A button or field used in every login flow |
| Environment variable | A value that changes by environment | The website URL for development, staging, and production |
| Generated data | Data that needs to be valid, unique, and optionally of a specific general format | A random name or date used when creating a new account |
| Data file | Executing the same test with many different inputs | Testing login with a list of different usernames (CSV/XLS/XLSX) |
5. Choosing Locators/Identifiers
When identifying an element, work down this list and stop at the first option that is genuinely available and stable.
| Locator type | Example | Notes |
|---|---|---|
| Data/Test IDs | [data-testid="submit-button"] |
Purpose-built for testing; not tied to styling or content |
| Unique IDs | #username |
Fast and unique, but avoid auto-generated or dynamic IDs |
| ARIA Roles/Labels | [role="button"][aria-label="Submit"] |
Reliable and improves accessibility coverage |
| Names/Labels | input[name="email"] |
Strong for forms; can shift if business logic changes |
| CSS Classes | .btn-primary |
Readable, but styling classes are often refactored |
| Text Content | //button[text()='Submit'] |
Fine for static, unique text |
| Relative XPath with Attributes | //span[@class='ant-select-selection-wrap' and text()='Tags'] |
Use only when nothing above is available; keep it shallow |
| CSS Hierarchy | nav > div > span.menu-label |
Brittle because it breaks when the DOM structure shifts |
| Absolute XPath | /html/body/div[1]/nav/div[2]/div/span |
Depends on the exact DOM hierarchy and element positions. Breaks easily when wrappers, containers, or page structure change |
Do
- Prefer stable, unique identifiers that will not shift with minor UI updates.
- Actively review and refine a suggested identifier rather than accepting the first one offered by a tool.
- Add an element image wherever possible. This provides a fallback if all other identifiers fail.
Avoid
- Position-based identifiers, such as "the third item in a list"; any reordering breaks them.
- State-based CSS classes such as
active,selected, andhidden. These change at runtime and cannot be relied on as stable locators.
6. Avoid Fixed Waits
- Use Wait Until Visible or Wait Until Not Visible when a reliable visibility condition exists. For example:
- Wait until a loading spinner is not visible before clicking Submit.
- Wait until a success message is visible before verifying it.
- Place a wait before an action that depends on an element being in a specific state. For example:
- If a button must become visible before it can be clicked, wait for it to be visible first.
- If an overlay must disappear before interacting with the page, wait until it is not visible.
- Set timeout values based on the actual load behavior of the page or application (see Wait Strategies and Timeouts for how timeouts are configured). For example:
- Use a longer timeout for pages or actions that are known to load slowly.
- Keep the timeout shorter for elements that should appear quickly.
- Avoid increasing every timeout simply to make a test pass.
- Don't use fixed waits when a visibility condition is available.
- Don't use unnecessarily large timeouts to hide synchronization problems.
- Use a fixed Wait only as a last resort when no reliable visibility condition exists.
7. Use the Interactive Browser for Partial Runs
An Interactive Browser can be used to record and execute actions.
- Use the Interactive Browser to run and validate part of a test without executing the entire test from the beginning.
- Validate the relevant section first, then execute the complete test to confirm the end-to-end flow.
- This is especially useful when:
- Developing or debugging a specific section of a test.
- Validating a new action or locator before executing the full test.
- Checking the behavior of a particular Action Group.
- Quickly reproducing and investigating a failure.
8. Test Integrity
- Each test must execute with no hidden dependency on another test running first.
- Add Verify actions before or after critical actions to confirm the application is in the expected state at each key point.
- Execute the test individually and confirm it passes before adding it to a shared tagged run set.
- If the test uses data-driven inputs, review the data file and confirm all variable bindings before marking it Ready.
9. Use Test States Consistently
Keep the test state up to date as the test progresses through its lifecycle. This gives the team clear visibility into which tests are ready to execute, require review, or need attention.
For example:
10. Executing Your Tests
Use Run Mode intentionally to control which tests are executed, when they run, and how they are executed.
Use tags to build intentional test suites
See Tags and folders for how to choose tags.
- Define a small number of standard tags for commonly used test suites, such as Smoke and Regression.
- Avoid creating ad hoc tag combinations for every execution. Standardized tags make execution predictable and easier to understand.
Name runs clearly
- Give each execution a meaningful name so its purpose is clear when reviewing execution history.
- Avoid relying on generic names or timestamps alone.
Example: Regression — Prerelease UMAI v2.4
Use parallel execution for independent tests
- A parallel run can reduce overall test time when tests are independent.
- Avoid parallel execution when tests share accounts or data.
Use Scheduled Execution for scheduled runs
- Use Scheduled Execution to automatically execute tests at a defined date or time, rather than for active debugging. For example:
- A nightly Regression run against the development environment.
- A Smoke run before a release window.
- Name scheduled runs by cadence and purpose, such as "Nightly Regression UMAI Dev".
- Use tags deliberately so scheduled runs include only the intended tests.
- Avoid overlapping schedules against the same environment when tests share data or state.
- Assign someone to review scheduled run results and investigate failures.
- Review schedules periodically and remove outdated tags, environments, or retired tests.
- When actively investigating a failure, run the test manually rather than waiting for a scheduled run. The Interactive Browser can be used to investigate a specific section of a test.
- Execute the complete test using the Run button after fixing an issue to confirm the end-to-end flow.
Use Test Runner for unattended execution
- Use UMAI's Test Runner Docker image to execute tests in a containerized environment, such as a CI pipeline. Setup steps are in CI/CD Configuration.
- Use it where execution should be triggered by the pipeline rather than by a person. For example:
- A Smoke run on every pull request.
- A Regression run before a release build is promoted.
- Build the suite using the tag and naming practices above. Pipeline runs should use the same standard tags as everything else, and the suite name should say what it is and where it runs, such as Smoke UMAI Dev CI.
- Export the run configuration from the web app rather than writing it by hand, so the tests, environment, and browsers match what you selected in the UI.
- Keep the exported configuration in source control next to the pipeline definition, so the test suite is versioned with the code it verifies.
- Store the API key as a secret in your CI system and inject it at runtime. Never commit it.
- Set an expiry on the API key and track when it needs to rotate. An expired key stops the run before any test is executed.
- Let the run result decide whether the build passes. Distinguish a failing test from a run that could not start, and treat the second as a pipeline problem rather than a defect.
- Publish the test report so results are visible in the pipeline, including when the run fails.
- Choose browsers deliberately. Safari is not available in the container, so any Safari coverage has to run elsewhere.
- Avoid running a pipeline execution and a scheduled execution against the same environment at the same time when tests share data or accounts.
- Assign someone to own pipeline failures, as with scheduled runs. An unattended run is only worth having if someone acts on the result.
Check across browsers and devices
For anything business critical, such as login or checkout, periodically check that it also works correctly in other browsers your users rely on. UMAI's random browser selection feature in run configuration is useful for this.
11. Documenting as You Go
- Add a short description to every test explaining what it checks and why it matters, not just what actions it performs.
- Keep descriptions current. An outdated description causes incorrect conclusions when a test fails.
12. Handling Flaky Tests
- Investigate the cause. Common causes include:
- Unstable locators sensitive to minor UI changes.
- Timing issues, such as the test acting before the page or element is ready.
- Shared environment states, such as tests interfering with each other in parallel runs.
- Data dependencies, such as a test relying on data created or modified by another test.
- Keep an execution list of known flaky tests so your team can interpret results with the right context.
- If a test has been flaky for a long time without resolution, retire it from active run sets until it is properly fixed. A flaky test in a Smoke run can create uncertainty about every result.
13. Fixing a Test
When a single test breaks
- Read the execution report before touching the test. Confirm which action failed and what the error says.
- Check the action in previous executions before the failure. A previous action may have executed unexpectedly, leaving the failing action in the wrong state.
- If the failure is right after a page load, check whether it is a genuine change or a wait/timeout that was too short before assuming the locator is wrong.
- Move the test to Repair, fix the root cause, then move it to Revalidate. Run it end-to-end before returning it to Ready.
When a change affects many tests
- If a shared flow has changed, such as a login screen, navigation pattern, or form, look for the relevant Action Group first.
- Fixing the Action Group fixes all tests that use it. Fixing individual tests one by one creates inconsistency and misses cases.
- Before modifying a shared Action Group, list all dependent tests. Retest every affected case after the change.
- If a UI change affects locators across many tests, perform a systematic sweep using tags or folders to find and update all affected tests rather than fixing them as they fail.
Documenting the impact
- When you repair a test, label each update clearly when saving. Add a short description for every fix or update so reviewers can understand what changed, why it changed, and which area of the test suite was affected.
- If the same area of the application causes repeated breakage, flag it. Recurring instability in one area is a signal worth surfacing to the development team.