Overview
Stagehand makes web navigation simple by allowing you to describe actions in natural language. This example shows how to navigate through a multi-step apartment search workflow.Multi-Step Navigation Example
This example demonstrates navigating through filters and options on an apartment search site:Using Custom System Prompts
You can customize Stagehand’s behavior with system prompts:Direct Page Navigation
For simpler navigation tasks, you can use directact() calls:
Working with Multiple Pages
Stagehand supports working with multiple browser pages simultaneously:Key Concepts
observe() and act()
Theobserve() method lets you preview actions before executing them with act(). This is useful for:
- Caching element locations
- Debugging navigation flows
- Building more robust automation
Waiting for UI Updates
Always add appropriate delays between actions to allow UI elements to load and respond:System Prompts
Customize Stagehand’s behavior with system prompts to:- Add special command shortcuts
- Transform user inputs
- Implement custom navigation logic
Page Context
When working with multiple pages, specify the target page using thepage option in act() and observe().
Best Practices
- Wait for navigation - Always ensure pages have loaded before interacting
- Use observe() for complex flows - Preview and cache actions for reliability
- Verify results - Check URLs or page content to confirm successful navigation
- Handle errors gracefully - Navigation can fail due to network issues or UI changes
Next Steps
- Learn about form filling for data input
- See data extraction to retrieve information
- Explore multi-step automation for complex workflows