Skip to main content
Learn essential patterns for reliable web automation using VisionAgent. This tutorial covers real-world scenarios based on common automation challenges.
Prerequisites: Complete Your First Agent tutorial before starting.

What You’ll Learn

This tutorial teaches you how to:
  • Open and control applications
  • Handle dynamic text and buttons
  • Work with forms and input fields
  • Manage popups and overlays
  • Use visual relationships for element selection
  • Implement proper wait strategies

Tutorial Application

We’ll use the SauceDemo web application for our examples - a test e-commerce site perfect for learning automation patterns.

1. Opening Applications

Learn different ways to launch applications and websites.
Always add wait times after opening applications to ensure they’re fully loaded before interacting with them.

2. Clicking Text and Dynamic Elements

Handle text-based interactions with proper error handling and dynamic content.

Basic Text Clicking

Handling Text Detection Issues

When text appears on multiple lines, use partial matching:
When overlay text merges with background text:
Handle text with inconsistent spacing:

3. Working with Icons and Buttons

Interact with visual elements beyond text.
AI elements work best with:
  • High color contrast against background
  • Clear rectangular shapes
  • Distinct visual properties

4. Form Filling and Text Input

Efficiently fill forms with structured data.

5. Visual Relationships

Use spatial relationships to find elements precisely.
Visual relationships are powerful for targeting elements in dynamic layouts:

6. Wait Strategies

Implement proper waiting for reliable automation.

7. Keyboard Shortcuts

Use keyboard shortcuts for efficient navigation.

8. Handling Popups and Dynamic Content

Manage unexpected UI elements gracefully.

Helper Functions

Since VisionAgent focuses on core functionality, here are useful helper functions for common patterns:

Complete Example: E-commerce Purchase Flow

Here’s a complete automation combining all patterns:

Best Practices Summary

Always Wait

Add appropriate waits after actions that trigger page changes

Use Fallbacks

Implement alternative locators when elements might vary

Handle Errors

Use try-except blocks for actions that might fail

Be Specific

Use visual relationships to target elements precisely

Troubleshooting Common Issues

  • Increase wait times
  • Use more specific locators
  • Check if element is scrolled out of view
  • Try AI elements for complex visuals
  • Use contains() for partial matching
  • Try regex patterns for flexible matching
  • Consider using AI elements as fallback
  • Reduce unnecessary waits
  • Use batch operations where possible
  • Enable parallel execution for independent tasks

Next Steps

Now that you’ve mastered these patterns:

Android Automation

Apply these patterns to mobile automation

Data Extraction

Learn to extract structured data from UIs

AI Agent Instructions

Write instructions for autonomous agents

Example Automations

Explore real-world automation examples