TestPerfect
Copy-paste ready test cases for every feature — start from the closest one and edit the selectors to match your app.
Simple login flow with assertions
Navigate to https://example.com/login
Fill #email with testuser@example.com
Fill #password with SecurePass123!
Click Login
Assert page contains "Dashboard"
Print ✅ Login successful!Fill a form and capture the submitted ID
Navigate to https://example.com/signup
Fill #firstName with John
Fill #lastName with Doe
Fill #email with john.doe@example.com
Fill #password with MySecurePass123
Click #subscribe checkbox
Click "Create Account" button
Capture text of .confirmation-id as accountId
Print Your account ID: {{accountId}}
Assert {{accountId}} is not emptyScroll, drag, type, and press keys
Navigate to https://example.com/products
// Scrolling
Scroll down 5
Click "Load More"
Scroll to #featured-section
Scroll to bottom
// Mouse interactions
Click #product-1
Hover over .rating
Drag #item to .trash
// Keyboard interactions
Type search term
Press Enter
Focus on #filter
Press Ctrl+A
Press Ctrl+C
// Text input with delay
Click #email
Type user@example.com
Press Tab
Type password123
Press Enter
// Advanced: Hover and menu
Hover over .profile-menu
Click .settings-option
Screenshot viewport as menuScreenshotForce actions on disabled or hidden elements
Navigate to https://example.com/form
// Test disabled state UI
Assert #submitBtn is disabled
Force click #submitBtn
Assert page shows error "Form incomplete"
// Force fill disabled field
Assert #locked-field is not editable
Force fill #locked-field with test-value
Assert #locked-field contains "test-value"
// Test hidden elements
Force hover .hidden-menu
Assert .menu-item is visible
// Verify element states
Assert #button is enabled
Assert #field is editable
Assert .spinner is stable
Assert button receives eventsWork with alerts, confirms, and prompts
Navigate to https://example.com/settings
// Handle confirm dialogs
Click "Delete Account"
Get dialog message as confirmMsg
Print Confirmation: {{confirmMsg}}
Accept confirm
// Handle prompts
Click "Add Item"
Get dialog message as promptMsg
Accept prompt with "New Item Name"
Assert page contains "Item added"
// Handle alerts
Click "Show Info"
Assert dialog contains "Information"
Accept alert
// Dismiss dialogs
Click "Dangerous Action"
Dismiss alert
Assert page still displays "Settings"Automatically fill entire forms with smart dummy data
Navigate to https://example.com/register
// Auto-fill the entire registration form
Fill all information in register page
Print Form auto-filled with dummy data
// Verify fields were filled
Assert page contains "test@example.com" or page contains "testuser"
// Submit the form
Click Register
Assert page contains "Account created"
// Another example: Fill specific form section
Navigate to https://example.com/profile
Fill complete form in .profile-section
Click Save
Assert page contains "Profile updated"
// Auto-filled values:
// Email fields → testuser@example.com
// Password fields → TestPass@123!
// Name fields → John Doe
// Phone fields → 5551234567
// Address fields → 123 Main Street
// And more based on field names...Various assertion types and patterns
Navigate to https://example.com/dashboard
Capture text of .order-count as orderCount
Capture text of .status as status
// Basic assertions
Assert {{status}} equals "Active"
Assert {{orderCount}} > 0
Assert page contains "Welcome"
// Negating matchers
Assert {{status}} not equals "Cancelled"
Assert {{orderCount}} is not empty
// Soft assertions (won't fail test)
Soft assert {{status}} equals "Expected"
Soft assert {{orderCount}} > 100
// Auto-retry assertions (wait and retry)
Expect {{status}} equals "Ready" with retry 5000ms
// Poll conditions
Expect poll {{loading}} until "false" timeout 10000
// Element state assertions
Assert #submitBtn is enabled
Assert .spinner is hidden
Assert input is editable
Assert button receives eventsWork with lists, tables, and array data
Navigate to https://example.com/products
Count items in .product-list
Print Total products: {{itemCount}}
// Get specific item
Get item 1 from .product-list as firstProduct
Print First product: {{firstProduct}}
// Assert conditions
Assert all items in .product-list contain "$"
Assert any item in .warnings contains "Stock Low"
// Filter operations
Assert filtered items in .status with "In Stock" count > 0
// Get all items
Get all items from .products as productsList
Print Products: {{productsList}}Handle errors and test edge cases
Navigate to https://example.com/form
// Test with invalid input
Fill #email with invalid-email
Click Submit
Assert page contains "Invalid email"
Screenshot full as errorState
// Test disabled state
[SKIP IF NOT AUTHENTICATED] Test admin features
[SKIP IF AUTHENTICATED] Test public features
// Soft assertions for warnings
Soft assert page contains "Warning"
Soft assert {{itemCount}} > 0
// Retry on transient failures
Expect {{status}} equals "Ready" with retry 5000ms
// Assert element not found behavior
[TRY]
Assert #optional-field is visible
[CATCH]
Print Optional field not visible
// Force click if needed
Force click #troublesome-button
// Log for debugging
Print Error state captured
Screenshot viewport as errorScreenshotCreate test data via API, then test via UI
// API Setup: Create user via API
POST https://api.example.com/users with {"email":"qa@test.com","name":"QA User"} as userResp
Extract {{userResp}}.id as userId
Extract {{userResp}}.token as authToken
Set auth token as Bearer {{authToken}}
Print Created user: {{userId}}
// UI Test: Login and verify
Navigate to https://example.com/login
Fill #email with qa@test.com
Fill #password with DefaultPass123
Click Login
Assert page contains "Welcome QA User"
// API Verification: Verify user data
GET https://api.example.com/users/{{userId}} as userDetails
Assert {{userDetails}} contains status 200Make API calls and validate responses
// GET request
GET https://api.example.com/users/123 as user
Assert {{user}} contains status 200
// POST request
POST https://api.example.com/orders with {"item":"Book","qty":2} as order
Extract {{order}}.id as orderId
Assert {{orderId}} is not empty
// Extract nested data
Extract {{order}}.items.0.name as itemName
Print First item: {{itemName}}
// API assertions
Assert {{order}} contains status 201
Assert {{order}}.total > 0
// List from API
GET https://api.example.com/products as products
Assert {{products}} contains status 200
Soft assert {{products}} contains "itemCount"Run same test with different data
// Test 1: Admin user
Navigate to https://example.com/login
Fill #email with admin@company.com
Fill #password with AdminPass123
Click Login
Assert page contains "Admin"
Clear session
// Test 2: Manager user
Navigate to https://example.com/login
Fill #email with manager@company.com
Fill #password with ManagerPass123
Click Login
Assert page contains "Manager"
Clear session
// Test 3: Regular user
Navigate to https://example.com/login
Fill #email with user@company.com
Fill #password with UserPass123
Click Login
Assert page contains "Dashboard"
Clear session
Print All 3 test variations completed! ✅Use test data rows to run tests with multiple user accounts
Navigate to https://example.com/register
// Use test data columns directly in steps
Fill #firstName with {{firstName}}
Fill #lastName with {{lastName}}
Fill #email with {{email}}
Fill #password with {{password}}
Fill #confirmPassword with {{password}}
Check #terms checkbox
Click "Create Account" button
// Verify registration success
Assert page contains "Welcome {{firstName}}"
Assert page contains "{{email}}"
Print Account created for {{firstName}} {{lastName}}
// Logout
Click "Sign Out"
// Test Data Setup (from Test Data tab):
// Columns: firstName, lastName, email, password
// Row 1: John, Doe, john.doe@example.com, SecurePass123!
// Row 2: Jane, Smith, jane.smith@example.com, SecurePass456!
// Row 3: Bob, Johnson, bob.johnson@example.com, SecurePass789!
// When you run this test:
// ✅ Run 1: Creates John Doe account with john.doe@example.com
// ✅ Run 2: Creates Jane Smith account with jane.smith@example.com
// ✅ Run 3: Creates Bob Johnson account with bob.johnson@example.comCapture screenshots and log progress
Navigate to https://example.com/dashboard
Print Starting test...
// Take full page screenshot
Screenshot full as homepage
// Take element screenshot
Screenshot #dashboard-widget as widget
// Take viewport screenshot
Screenshot viewport as viewport
// Log progress
Print Filling form...
Fill #email with test@example.com
WriteLine Email filled
// Log with variables
Capture text of .status as status
Print Current status: {{status}}
Log All steps completed
Print Test finished successfully! ✅E-commerce checkout with multiple steps
Navigate to https://shop.example.com/products
Click "Add to Cart" button
Assert page contains "1 item in cart"
Click "Proceed to Checkout"
Fill #name with Jane Smith
Fill #address with 123 Main St
Fill #city with New York
Select #state with NY
Click "Continue to Payment"
Screenshot full as checkoutStep
Fill #card with 4242424242424242
Fill #expiry with 12/25
Click "Place Order"
Capture text of .order-number as orderId
Assert {{orderId}} is not empty
Print Order ID: {{orderId}}Test different user roles in same test
// Admin Login
Navigate to https://example.com/login
Fill #email with admin@company.com
Fill #password with AdminPass123
Click Login
Assert page contains "Admin Dashboard"
Save session as admin
// Manager Login
Navigate to https://example.com/login
Fill #email with manager@company.com
Fill #password with ManagerPass123
Click Login
Assert page contains "Manager Dashboard"
Save session as manager
// Test Admin Features
Load session admin
Navigate to https://example.com/admin/users
Assert page contains "Edit"
Assert page contains "Delete"
// Test Manager Features
Load session manager
Navigate to https://example.com/reports
Assert page contains "View Only"
Assert page contains "Cannot Edit"Full end-to-end test combining all features
// Setup: Create test data via API
POST https://api.example.com/auth with {"user":"qa","pass":"qwerty123"} as auth
Extract {{auth}}.token as token
Extract {{auth}}.userId as userId
Set auth token as Bearer {{token}}
Print User created: {{userId}}
// Save auth session
Save session as qa_user
Print Session saved
// Navigate and test
Navigate to https://example.com/dashboard
Assert page contains "Welcome"
Screenshot full as dashboard
// Perform actions
Click #create-order
Fill #productName with "Test Item"
Fill #quantity with "5"
Click #save
Assert page contains "Order created"
Capture text of .order-id as orderId
Print Order created: {{orderId}}
// Verify via API
GET https://api.example.com/orders/{{orderId}} as orderDetails
Assert {{orderDetails}} contains status 200
Extract {{orderDetails}}.status as orderStatus
Assert {{orderStatus}} equals "pending"
// Test another role
Navigate to https://example.com/login
Fill #email with admin@company.com
Fill #password with AdminPass123
Click Login
Save session as admin_user
// Admin verification
Load session admin_user
Navigate to https://example.com/admin/orders/{{orderId}}
Assert page contains "Order ID: {{orderId}}"
Assert page contains "View Only"
Screenshot full as adminView
// Cleanup (optional)
Clear session
Print Test completed successfully! ✅For more help, contact support or check the GitHub repository.
Last updated: 2026-06-24