How-to
URL assert (toHaveURL)
URL assert (toHaveURL)
Asserts the tab URL. Value is a path, a URL, or a /pattern/flags string (the worker compiles a regular expression). Otherwise the string goes to Playwright as a glob: a trailing ** glued to the last segment (listing**) does not match a URL that ends on that segment. A path-only assert does not see the host: the same path on the root and on a team subdomain is a different screen. No Target. INLINE only.
Step model
action_name | toHaveURL |
| Group | Expect |
| Target | Unused |
| Value | Required (url) |
| expected_value | Unused |
| TEST_ACCOUNT | Forbidden |
| Do not confuse with | waitForURL, goto |
Target/Value facts match the source-of-truth catalog and Autotest step.
Prerequisites
- Navigation already finished or will finish within the timeout.
Steps
- Add a
toHaveURLstep. - Put the expected address or
/pattern/flagsin Value. - Source must be
INLINE. - Save.
The step is stored on the autotest. Next - neighbouring steps or autotest run creation.
Examples
Exact path
Fields in the UI:
| Field | Value |
|---|---|
action_name | toHaveURL |
| Target | empty |
| Value | **/settings/profile |
| value_source_type | INLINE |
Step JSON fragment (copy-paste):
{
"action_name": "toHaveURL",
"value_text": "**/settings/profile",
"value_source_type": "INLINE"
}Regular expression
Fields in the UI:
| Field | Value |
|---|---|
action_name | toHaveURL |
| Target | empty |
| Value | /\/projects\/\d+$/ |
| value_source_type | INLINE |
Step JSON fragment (copy-paste):
{
"action_name": "toHaveURL",
"value_text": "/\\/projects\\/\\d+$/",
"value_source_type": "INLINE"
}Common mistakes
- Do not confuse with waitForURL: toHaveURL is an assert in the report.
- Do not copy onto
toHaveURLa glob with a trailing**(**/web/ru/project/listing**) that worked onwaitForURL. For the assert use/\/web\/ru\/project\/listing/or a glob without the tail. - A path-only check can stay green on a 404 page on another host. Put the host in the pattern or keep a
toBeVisibleon unique screen text. - Breakdown: How to author autotest steps without false failures.
Screenshots
Screenshots of the step form for toHaveURL will be added here in a later pass.
Did this page help?