Web Automation Best Practices
Building reliable web automation requires understanding common challenges and applying proven solutions. This guide covers essential techniques and pitfalls to avoid when working with web agents.Common Challenges & Solutions
1
Managing Wait Times
Web pages load asynchronously, and content may appear at different rates. While Notte handles most timing automatically, you can add explicit waits when needed.Add custom wait times:When to use explicit waits:
- After triggering actions that load new content
- Before interacting with dynamically rendered elements
- When dealing with slow API responses or animations
- After page navigation to ensure full load
2
Handling Popups and Modals
Popups, cookie banners, and modals are common obstacles in web automation. The fastest and most reliable way to dismiss them is using the Escape key.Close popups with Escape:Handle optional popups:If a popup doesn’t always appear, use This prevents your workflow from crashing when the popup is absent.
raise_on_failure=False to allow the action to fail silently:3
Resolving Multiple Element Matches
Playwright operates in strict mode, meaning selectors must resolve to exactly one element. When multiple elements match, you’ll see an error.Common error:Solution - Select specific element:Append Index options:
>> nth=0 to your selector to select the first matching element:>> nth=0- First element>> nth=1- Second element>> nth=-1- Last element
4
Selector Best Practices
Prefer stable selectors:Use selectors that are less likely to change:Use text selectors carefully:Text content can change or be translated. When using text selectors, consider partial matches:
- ✅
data-testidattributes - ✅ Semantic roles and labels
- ✅ Unique IDs
- ⚠️ CSS classes (can change frequently)
- ❌ XPath with positional indices
Common Pitfalls to Avoid
Not accounting for loading states
Not accounting for loading states
Problem: Interacting with elements before they’re readySolution: Use explicit waits or wait for loading indicators to disappear
Using fragile selectors
Using fragile selectors
Problem: Selectors break when page structure changesSolution: Prefer semantic selectors and data attributes over positional CSS selectors
Ignoring error handling
Ignoring error handling
Problem: Workflows crash on minor issues like missing optional elementsSolution: Use
raise_on_failure=False for optional actions and implement proper error recoveryNot handling multiple element matches
Not handling multiple element matches
Problem: Playwright’s strict mode violations when selectors match multiple elementsSolution: Use
>> nth=0 or make selectors more specificNot testing with real-world conditions
Not testing with real-world conditions
Problem: Agents work in development but fail in productionSolution: Test with realistic network conditions, slow connections, and edge cases
Leverage Playwright Ecosystem
The Playwright ecosystem is mature and well-documented, with extensive resources available online. LLMs have been trained on thousands of Playwright examples, making them excellent at helping you solve complex automation challenges. Notte is fully Playwright-compatible, giving you direct access to the underlying Playwright page object whenever you need it:- Use any Playwright method directly on
session.page - Leverage the vast Playwright documentation and community resources
- Combine Notte’s high-level automation with Playwright’s low-level control
- Ask LLMs for help with Playwright-specific solutions that work seamlessly with Notte
Additional Resources
Need help optimizing your automation?
Our team has extensive experience debugging and optimizing complex web automation workflows. Book a call to discuss your specific challenges.

