Technical Lessons from Building Robust Automation
Here are some key lessons that made the automation reliable.
1. Avoid Hard Waits
Instead of using fixed sleep times:
- Wait for elements to be visible
- Wait for buttons to be enabled
- Wait for network to be idle
This dramatically improves stability.
2. Use Roles and Accessible Selectors
Selectors based on roles and names are more stable than CSS paths.
Example:
page.get_by_role(“button”, name=”Create action”)
This makes tests resilient to UI layout changes.
3. Handle Popups and Tabs Properly
Modern apps often open new pages. Playwright’s popup handling ensures the script stays in control.
4. Build Reusable Helper Functions
Reusable click and wait utilities reduce duplication and increase consistency.
5. Think Like a User, Not a Script
Automate real user journeys — not individual clicks.