Prerequisites: Make sure you’ve completed the installation before starting this tutorial.
What You’ll Build
You’ll create an agent that:- Opens Amazon in a web browser
- Searches for a product
- Verifies the search results
- Generates a report of the automation
Building Your Agent
Create Your Agent Script
Create a new Python file Run the script:The script will:
amazon_shopping.py and add the following code:- Agent
- Hybrid Agent
- Open Amazon in your default browser
- Search for “nike shoes”
- Verify the cart contents
- Generate an HTML report of the automation
Understanding Your Code
Let’s break down what each part does:
Agent Initialization
- Creates a vision agent that can see and interact with your screen
- Enables debug logging to see what’s happening
- Sets up HTML reporting to review the automation later
Browser Control
- Opens a new browser window with Amazon
- Waits for the page to load
Element Interaction
- Finds and clicks the search box
- Types the search query
- Presses Enter to search
Information Extraction
- Uses AI to understand what’s on the screen
- Returns a natural language response
Enhancing Your Agent
Try these modifications to learn more:1. Add Product to Cart
2. Use Different Selectors
3. Extract Product Information
Common Issues and Solutions
Browser doesn't open
Browser doesn't open
- Check if you have a default browser set
- Try using a specific browser path
- Ensure AskUI Agent OS is running
Element not found
Element not found
- Add wait times for dynamic content
- Use more specific locators
- Check if the element is visible on screen
Script runs too fast
Script runs too fast
- Add
agent.wait()between actions - Enable visual debugging with screenshots
- Use SimpleHTMLReporter
What You’ve Learned
Congratulations! You’ve successfully:- ✅ Created your first AskUI agent
- ✅ Automated browser interactions
- ✅ Used AI to verify screen content
- ✅ Generated automation reports
Next Steps
Element Selection
Learn advanced techniques for finding and selecting UI elements
Data Extraction
Extract structured data from any UI
Configure AI Models
Use different AI models for specific tasks
Best Practices
Learn patterns for reliable automation