.toHaveAttribute(attribute, value)
Asserts the element has attribute strictly equal to value.
Usage
expect(value).toHaveAttribute(attribute, value)
Parameters
attribute(String): Name of attribute. See.getAttributefor available attributes.value(Any): Value to compare against the element's attribute.
Returns
Promise: A promise that resolves if the assertion is successful.
Support
| Platform | Supported |
|---|---|
| iOS | Yes |
| Android | Yes |
| Web | Yes |
Examples
Check if the button is enabled:
const { element, by, expect } = require("appdriver");
(async () => {
const $button = await element(by.label("button"));
await expect($button).toHaveAttribute("enabled", true);
})();