Skip to content

UI.doesNotHaveAttribute()

Asserts that an element does not have a specific HTML attribute.

  • If value is not provided, the assertion passes when the attribute is not present on the element.
  • If value is 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

ParameterTypeDescription
elementstringTarget element — by CSS or XPath selector
namestringAttribute name to check (e.g. disabled, aria-label, href)
valuestring(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.