Get Attributes
get_attributesRetrieve a specific HTML attribute or all attributes from the first element matching a CSS/XPath selector. Returns the attribute value or dictionary, with timeout option.
Instructions
Get a specific HTML attribute (or all attributes) from the first-matching 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.
attribute: Specific HTML attribute to retrieve. When omitted, return
all HTML attributes of the first 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'.
This is a read-only operation: It finds elements to get the requested data, but it does not make any modifications to those elements.
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 |