Debugging Failed Tests
This guide explains how to identify, understand, and fix test failures in TrueAssert.
Overview
When a test fails, TrueAssert provides detailed information to help you debug:
Error messages for each failed step
Screenshots captured at failure points
Execution logs with timestamps
Step-by-step execution status
Understanding Test Failures
Test Execution Status
A test can fail at different stages:
IN_QUEUE → FAIL:
Test failed before execution started
Possible causes: No agents, queue error, login failure
RUNNING → FAIL:
Test failed during execution
One or more steps failed
Check individual step results
SUCCESS:
All steps completed successfully
No debugging needed
Step Execution Status
Individual steps can fail:
PENDING → FAIL:
Step never executed (test failed earlier)
RUNNING → FAIL:
Step executed but failed
Error message available
Screenshot captured (if enabled)
Common Failure Types
1. Selector Not Found
Error Message: Element not found: //button[@id='submit']
What It Means:
Selector doesn't match any element on the page
Element doesn't exist
Element hasn't loaded yet
Page structure changed
How to Fix:
Check Selector: Verify selector is correct
Inspect Page: Use browser DevTools to check if element exists
Add WAIT: Add WAIT step before interaction if element loads slowly
Update Selector: Fix selector if page structure changed
Use Alternative Selector: Try different selector if available
Example Fix:
Before: CLICK //button[@class='submit-btn']
After: WAIT //button[@id='submit']
CLICK //button[@id='submit']2. Timeout Waiting for Element
Error Message: Timeout waiting for element: //div[@class='loading']
What It Means:
Element didn't appear within timeout period
Page loading slowly
Element condition not met
How to Fix:
Increase Timeout: If element takes longer to load
Check Element: Verify element actually appears
Fix Selector: Ensure selector is correct
Add Delay: Add explicit wait before checking
3. Element Not Clickable
Error Message: Cannot click element: Element is not clickable
What It Means:
Element is hidden or disabled
Element is covered by another element
Element is not in viewport
How to Fix:
Scroll to Element: Add SCROLL step before CLICK
Wait for Visibility: Add WAIT step for element to be visible
Check Element State: Verify element is enabled
Remove Overlay: Wait for overlays to disappear
Example Fix:
Before: CLICK //button[@id='submit']
After: SCROLL (scroll to element)
WAIT //button[@id='submit'] (wait for visible)
CLICK //button[@id='submit']4. Login Failed
Error Message: Login flow failed: [specific error]
What It Means:
Login test steps failed
Authentication unsuccessful
Session validation failed
How to Fix:
Check Credentials: Verify username/password are correct
Review Login Test: Check login test steps are correct
Update Selectors: Fix selectors in login test if page changed
Check Login URL: Verify login URL is correct
5. Session Load Failed
Error Message: No session data found for domain or Session load failed
What It Means:
No session exists for project's domain
Session expired or invalid
Domain mismatch
How to Fix:
Clear Session: Clear old session data
Re-run Test: Create new session
Check Domain: Verify session domain matches test URL domain
Disable Session: Uncheck "Use Predefined Session" if not needed
6. Navigation Failed
Error Message: Navigation failed: [URL] or Page load timeout
What It Means:
URL is invalid or inaccessible
Page takes too long to load
Network error
How to Fix:
Verify URL: Check URL is correct and accessible
Check Network: Verify network connectivity
Increase Timeout: If page loads slowly
Test Manually: Verify URL works in browser
Debugging Workflow
Step 1: Identify the Failure
Go to test detail page
Check execution status badge (FAIL)
Review error message
Identify which step failed
Step 2: Review Error Details
Click on failed step
Read error message
View screenshot (if available)
Check execution logs
Step 3: Analyze the Issue
Understand Error: What does the error mean?
Check Context: What happened before the failure?
Verify Selector: Is selector correct?
Check Timing: Was element loaded?
Step 4: Fix the Issue
Update Selector: Fix incorrect selector
Add WAIT: Add wait if timing issue
Add SCROLL: Scroll if element not visible
Fix Value: Correct input value if wrong
Step 5: Re-run and Verify
Save changes
Run test again
Verify fix worked
Repeat if still failing
Using Screenshots
When Screenshots Help
Screenshots are valuable for:
Visual Verification: See what page looked like
Selector Issues: Verify element exists and is visible
State Analysis: Understand page state at failure
Debugging: Compare expected vs actual state
Viewing Screenshots
Go to execution detail page
Find failed step
Click screenshot thumbnail
View full-size screenshot
Compare with expected state
Screenshot Analysis
What to Look For:
Is the element visible?
Is the element in the correct state?
Are there overlays blocking interaction?
Has the page structure changed?
Is the page fully loaded?
Reading Execution Logs
Log Information
Execution logs contain:
Timestamps: When each step executed
Status Changes: Step status transitions
Error Messages: Detailed error information
Command Details: What command was executed
Log Analysis
Look For:
Timing Issues: Steps executing too fast
Sequence Problems: Steps in wrong order
Selector Issues: Selector not matching
State Problems: Page not in expected state
Common Debugging Scenarios
Scenario 1: Intermittent Failures
Symptom: Test fails sometimes but not always.
Possible Causes:
Timing issues (race conditions)
Network delays
Dynamic content loading
Element state changes
Solutions:
Add WAIT steps before interactions
Increase timeouts
Wait for specific conditions
Add explicit delays if needed
Scenario 2: Selector Breaking
Symptom: Test worked before but now fails.
Possible Causes:
Page structure changed
CSS classes changed
Element removed or moved
Dynamic IDs changed
Solutions:
Update selector to match new structure
Use more stable selectors (IDs, data-testid)
Use alternative selectors if available
Review page changes
Scenario 3: Login Issues
Symptom: Login flow fails consistently.
Possible Causes:
Credentials incorrect
Login page changed
Selectors incorrect
Confirmation element changed
Solutions:
Verify credentials in project settings
Review login test steps
Update login test selectors
Test login manually
Scenario 4: Session Issues
Symptom: Session validation always fails.
Possible Causes:
Session expired
Validation steps incorrect
Domain mismatch
Confirmation element changed
Solutions:
Clear session data
Update validation steps in login test
Verify domain matches
Re-create session
Best Practices
Prevention
Use Stable Selectors: Prefer IDs and data-testid
Add Waits: Wait for elements before interaction
Test Regularly: Run tests frequently to catch issues early
Review Changes: Check page changes before they break tests
Debugging
Start with Error: Read error message first
Check Screenshots: Visual verification helps
Review Logs: Understand execution flow
Test Manually: Reproduce issue manually
Fix Systematically: Fix one issue at a time
Maintenance
Update Selectors: Keep selectors current
Monitor Failures: Track common failure patterns
Improve Tests: Make tests more robust over time
Document Issues: Note common problems and solutions
Troubleshooting Checklist
When a test fails, check:
Related Topics
Viewing Results - Understand execution results
Running Tests - Execute tests
Troubleshooting Selectors - Fix selector issues
Session Management - Fix login issues
← Back to Documentation | Next: Understanding XPath Selectors →
Last updated