Appearance
UI.doesNotHaveAttribute()
Asserts that an element does not have a specific HTML attribute.
- If
valueis not provided, the assertion passes when the attribute is not present on the element. - If
valueis provided, the assertion passes when the attribute is either not present, or present with a different value.
If the assertion fails, the test will fail.
Usage
js
UI.doesNotHaveAttribute(element: string, name: string)
UI.doesNotHaveAttribute(element: string, name: string, value: string)Parameters
| Parameter | Type | Description |
|---|---|---|
element | string | Target element — by CSS or XPath selector |
name | string | Attribute name to check (e.g. disabled, aria-label, href) |
value | string | (Optional) Attribute value that must not match. |
Example
js
I.goTo("https://mystore.com")
I.click("Login")
I.fill("Username", "bruce")
I.fill("Password", "supersecret")
// assert that the #login-button is disabled
UI.doesNotHaveAttribute("#login-button", "disabled")In the example above, the test asserts that the disabled attribute is not set on the #login-button element.