Get Attributes
get_attributesRetrieve a specific HTML attribute or all attributes from a matching element using a CSS or XPath selector. Get values like href, src, or class to inspect page elements.
Instructions
Get a specific HTML attribute (or all attributes) from the selected element. Examples of possible attributes include href, src, value, class, id, name, type, aria-label, etc.
Args: selector: CSS selector or SeleniumBase-supported XPath selector. If multiple elements match, then only the first one is used.
attribute: Specific HTML attribute to retrieve. When omitted, returns
all HTML attributes of the matching element as a dictionary.
timeout: Maximum seconds to wait for the target element. Default: 5.Tool selection: - Need one or more HTML attribute values from a specific element -> use this tool. - Need to discover multiple matching elements or inspect their text -> use 'find_elements'. - Need visible text or HTML content -> use 'get_content'. - Need to check element presence/visibility -> use 'check_if_condition'.
If there's no matching element found within the timeout, then @handle_sb_errors returns details from the exception raised.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timeout | No | ||
| selector | Yes | ||
| attribute | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |