Actions15
- Session Actions
- Page Actions
- Script Actions
Page → Get Attribute
AI-generatedSummary
Gets the value of a specified attribute from a page element identified by a CSS or XPath selector.
Inputs
- sessionId (required) — Identifier of the browser session.
- selector (required) — CSS or XPath selector for the target element.
- attributeName — Name of the attribute to retrieve (e.g., 'href', 'class', 'id'). Defaults to empty string.
Output shape
string
The value of the specified attribute as returned by Playwright's page.getAttribute(). Returns an empty string if attributeName is not provided or the element has no such attribute.
Examples
Example 1: Retrieve the 'href' attribute of a link.
sessionId: 'session-123', selector: 'a.example-link', attributeName: 'href'