ActionResult
Each action returns anActionResult object with information about whether it succeeded or failed.
Structure
Fields
Execution status:
"SUCCESS" or "ERROR"Error description if status is
"ERROR", otherwise NoneAction-specific result data:
screenshot()returns{'screenshot_url': 'https://...'}- Most other actions return
{}
ISO 8601 timestamp of action completion
Unique identifier for the request (used for debugging and tracking)
Detailed page state information (when
include_context=True is passed to action). See Page Context below.ID of the tab where the action was executed (browser sessions only)
Usage Example
Page Context
Get detailed page state information with every action by passinginclude_context=True. This is useful for:
- Understanding the current viewport and page dimensions
- Tracking scroll position
- Verifying which tab executed the action
- Debugging coordinate-based interactions
- Monitoring page navigation
Requesting Page Context
PageContext Fields
Current page URL
Page title (from
<title> tag)Visible viewport width in pixels
Visible viewport height in pixels
Total page width in pixels (including scrollable area)
Total page height in pixels (including scrollable area)
Horizontal scroll position in pixels
Vertical scroll position in pixels
Device pixel ratio / zoom level (e.g., 2.0 for Retina displays)
ID of the tab this context belongs to
Whether this is the main/first tab in the browser session
Use Cases
Coordinate Debugging
Coordinate Debugging
Verify viewport dimensions match your expected coordinates. If your click at (1500, 800) fails, check if viewport_width < 1500.
Scroll Position Tracking
Scroll Position Tracking
Know exactly where on the page you are. Useful for calculating whether to scroll up or down to reach elements.
Multi-Tab Workflows
Multi-Tab Workflows
Track which tab each action executed on, especially useful when managing multiple tabs programmatically.
Responsive Testing
Responsive Testing
Verify that viewport changes (via
set_viewport()) took effect and check device_scale_factor for high-DPI testing.Page Navigation Verification
Page Navigation Verification
Example: Smart Scrolling
Response Examples
Successful Navigation
Failed Action
Screenshot Success
Error Handling
Common Error Types
| Error | Description | Solution |
|---|---|---|
| Navigation timeout | Page took too long to load | Increase wait time or check URL |
| Invalid coordinates | Click coordinates out of bounds | Verify x/y values are within viewport |
| Screenshot failed | Unable to capture screen | Check instance is active, retry |
| Connection error | Network/API connection issue | Check internet connection, retry |
| Invalid instance | Computer instance not found | Ensure create() succeeded, check termination |
Best Practices
Always Check Critical Actions
Always Check Critical Actions
Verify navigation and screenshot results before continuing
Log Errors for Debugging
Log Errors for Debugging
Store error messages and timestamps for troubleshooting
Implement Retry Logic
Implement Retry Logic
Retry failed actions with exponential backoff
Use Context Managers
Use Context Managers
Ensure cleanup happens even when errors occur