get_attributes
Retrieve HTML attribute values from the first element matching a CSS or XPath selector. Specify an attribute for its value, or omit it to get all attributes as a dictionary.
Instructions
Read HTML attributes from the first matching element.
Use this tool when you need the value of a specific HTML attribute, or all HTML attributes of an element. Attributes could be something such as 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.
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 |