Recommendation
Writing stable autotests
Writing stable autotests
Recommendation for ComplexQA autotest authors: how to reduce brittle Playwright steps on a verified team domain.
Why
An unstable locator, a new-tab click, and a long pause instead of waiting for an element cause false failures in an autotest run. A stable scenario uses precise Targets, explicit waits, and status READY only on finished CASE items.
How to work
- Prefer
ROLE,LABEL, andTESTIDover CSS with substring*=. - Wait for the element before an action:
waitForSelectorortoBeVisible, not a longwaitForTimeout. - Do not click links with
target=_blank. Open the address withgotoand a fullhttpsURL on a verified host. - Move repeated locators into the object repository.
- Set status
READYon aCASEonly after the scenario and syntax are checked. - Take login and password via
TEST_ACCOUNT, notINLINE.
Full step flow: Autotest step authoring. Typical false failures in the report: How to author autotest steps without false failures.
What to avoid
| Bad | Good |
|---|---|
CSS with *= «just in case» | Exact TESTID or ROLE plus name |
waitForTimeout of 10000 ms before every click | waitForSelector / toBeVisible on Target |
| Click a new-tab link | goto with a full URL |
| The same locator copied into ten autotests | One element in the object repository |
CASE at READY with draft steps | PENDING until the scenario is ready |
Example: brittle pause
json
{
"action_name": "waitForTimeout",
"value_text": "10000",
"value_source_type": "INLINE"
}Example: wait for an element
json
{
"action_name": "waitForSelector",
"target": { "kind": "TESTID", "value": "results-table" },
"timeout_ms": 15000
}Did this page help?