This script performs automated testing of a web form and API validation using JavaScript without framework.
- Navigate to https://demoqa.com/text-box in your browser
- Open Developer Tools (F12 or right-click → Inspect)
- Go to the Console tab
- type:
allow pasting
- Copy and paste the entire content of
solution.js
into the console - Press Enter to execute
- Watch the console output for validation results
- Form Automation: Fills form with test data using centralized configuration
- Form Submission: Submits form and waits for processing
- Output Validation: Extracts clean values after colons and validates exact matches
- API Testing: Validates JSONPlaceholder API response structure and individual keys
- Detailed Logging: Shows step-by-step validation results for each field
- Result Reporting: Prints "✅ All tests passed" if all validations succeed