Verification Actions
Auto-Browse provides a set of core assertions for verifying element states and content. These natural language commands make it easy to validate your application’s behavior.
Supported Assertions
Auto-Browse currently supports four fundamental assertion types:
Element Visibility
Check if elements are visible on the page:
// Verify element visibility
await auto("verify the login button is visible");
await auto("check if error message is displayed");
// Wait and verify
await auto("wait for loading spinner to disappear");
await auto("verify success message becomes visible");
Text Content
Verify the text content of elements:
// Exact text matching
await auto('verify heading text is "Welcome"');
await auto('check if error message says "Invalid input"');
// Dynamic content
await auto("verify message contains order number");
await auto("check if username is displayed correctly");
Element State
Check if elements are enabled:
// Button states
await auto("verify submit button is enabled");
await auto("check if save button is clickable");
// Input field states
await auto("verify email field is enabled");
await auto("check if password field is active");
Checkbox/Radio State
Verify if checkboxes or radio buttons are checked:
// Checkbox verification
await auto('verify "Remember me" checkbox is checked');
await auto('check if "Terms" box is selected');
// Radio button verification
await auto('verify "Express shipping" is selected');
await auto('check if "Credit card" option is checked');
Best Practices
1. Clear and Specific Assertions
// Good - Clear what to verify
await auto('verify login button shows "Sign In"');
await auto("check if error message is visible");
// Less Clear - Ambiguous
await auto("verify button");
await auto("check text");
2. Proper Wait States
// Good - Waits for state
await auto("wait for button to be enabled then verify");
await auto("verify message appears after loading");
// Not Recommended - No wait
await auto("verify button is enabled");
3. Error Handling
try {
await auto("verify form submission succeeded");
} catch (error) {
// Handle specific assertion failures
if (error.message.includes("not visible")) {
await auto("check if error message is shown");
}
}
Common Patterns
async function validateForm() {
// Check initial state
await auto("verify submit button is enabled");
// Submit empty form
await auto("click submit");
await auto("verify error message is visible");
await auto('check if error says "Required fields missing"');
}
2. Login Flow
async function verifyLogin() {
// Pre-login state
await auto("verify login button is visible");
// After login
await auto('type "user@example.com" in email');
await auto('type "password" in password');
await auto("click login");
await auto("verify welcome message is visible");
}
3. Interactive Elements
async function verifyInteractions() {
// Button states
await auto("verify button is enabled");
await auto("click button");
// Checkbox interactions
await auto("click remember me checkbox");
await auto("verify checkbox is checked");
}
Troubleshooting
Common verification issues and solutions:
- Visibility Issues
// Handle element visibility
await auto("scroll element into view");
await auto("verify element is visible");
- Timing Issues
// Handle loading states
await auto("wait for loading to complete");
await auto("verify content is visible");
- State Changes
// Handle dynamic states
await auto("click to change state");
await auto("verify new state is correct");
Next Steps