Appearance
UI.getAttribute()
Gets the value of an HTML attribute from an element.
Usage
js
var value = UI.getAttribute(element: string, name: string)Parameters
| Parameter | Type | Description |
|---|---|---|
element | string | Target element — by CSS or XPath selector |
name | string | Attribute name to retrieve (e.g. disabled, aria-label, href) |
Returns
Returns the value of the attribute as a string if it exists, or null if the attribute is not present on the element.
Example
js
let productID = UI.getAttribute(".product-card:nth(1)", "data-product-id")
TEST.log.info("Product ID: ", productID)In the example above, the test extracts the product ID from the first .product-card element from its data-product-id attribute and logs it to the test report.