Complete Example
Step-by-Step Explanation
1. Initialize OpenSteer
name. This name is used as the namespace for selector persistence, allowing you to build replayable scripts.
2. Launch the Browser
headless: false opens a visible browser window, which is helpful during development. In production, you can set headless: true for performance.
3. Navigate to a Page
4. Take a Snapshot
c="..." counter attributes on interactive elements, which you can use to target elements by number.
Snapshots are essential for:
- Understanding page structure
- Identifying element counters for targeting
- AI agent workflows
5. Interact with Elements
element: The counter number from the snapshot (e.g.,c="5")description: A natural language description for selector persistence
description, OpenSteer saves the selector for future runs. On subsequent executions, you can omit the element parameter:
6. Clean Up Resources
finally block to ensure resources are cleaned up, even if errors occur.
Running the Example
Make sure you have OpenSteer installed:Next Steps
Data Extraction
Learn how to extract structured data from web pages
Form Filling
See how to fill out and submit forms