Overview
The Get Attributes command provides functionality for:- Extracting attributes from DOM elements
- Using CSS selectors to target elements
- Extracting multiple attributes at once
- Filtering elements by various criteria
- Returning structured attribute data
Parameters
Element Locator Configuration
TheelementsLocator object configures how elements are targeted:
Locator Properties
Usage Examples
Extract Link Attributes
Extract Image Attributes
Extract Data Attributes
Extract with Session
Common Attributes
Link Attributes
- href: Link destination URL
- title: Link title/tooltip
- target: Link target (_blank, _self, etc.)
- rel: Link relationship
Image Attributes
- src: Image source URL
- alt: Alternative text
- width: Image width
- height: Image height
- title: Image title
Data Attributes
- data-*: Custom data attributes
- id: Element ID
- class: Element classes
- aria-*: Accessibility attributes
Output Structure
The command stores extracted attributes under the specified key:Single Element
Multiple Elements
Variable Support
The Get Attributes command supports variable interpolation in:- Selector: Use variables in CSS selectors
- Session ID: Use
#{UUID}for session tracking
Best Practices
- Use Stable Selectors: Prefer class names and IDs over text-based selectors
- Set Appropriate Timeouts: Configure timeouts for dynamic content loading
- Extract Relevant Attributes: Only extract attributes you need
- Handle Missing Attributes: Account for cases where attributes don’t exist
- Use Descriptive Keys: Use clear, descriptive key names for extracted attributes
Common Use Cases
- Link Extraction: Extract links from pages
- Image Extraction: Extract image sources and metadata
- Data Attribute Extraction: Extract custom data attributes
- Metadata Extraction: Extract element metadata
Related Commands
- Browser Open - Open browser before extraction
- Get Text Contents - Extract text instead of attributes
- HTTP Request - Fetch resources from extracted URLs