Assert the absense of an attribute on an element, or that the value of an attribute is not equals a given string.


// Assert that the element does not have an attribute
UI.doesNotHaveAttribute(target, attribute)
// Assert that the element does not have an attribute with an given value
UI.doesNotHaveAttribute(target, attribute, value)
Parameter Type Remarks
target string Expression to target an element. This can be a text, CSS selector, or XPATH selector.
attribute string Name of the attribute.
value string (Optional) Value that the attribute should not be equal to. Case-insensitive. If not provided, this command will simply assert that the attribute does not exist on the element.

Validate that an element should not be disabled

I.click("Login") // <- go to login page

// assert that the #login-button is disabled initially
UI.hasAttribute("#login-button", "disabled")

// fill the username and password fields
I.fill("Username", "john")
I.fill("Password", "supersecretpassword")

// assert that the #login-button is no longer disabled
UI.doesNotHaveAttribute("#login-button", "disabled")

In this example, we can use the UI.hasAttribute to test if the #login-button element is not disabled, when the Username and Password fields are filled.