← Back to libraryQuestion 332 of 468
🧪SeleniumBeginner

Assertions and Verifications

📖 Detailed Explanation:

Assertions (Hard Assert) are 'Critical Failures'—the test stops immediately and marks as FAILED. Verifications (Soft Assert) are 'Non-Critical'—the test logs the failure but continues to the next step and marks as FAILED at the end. Hard asserts are used for blocking issues, while soft asserts are used for non-blocking issues. Choosing the right type is crucial for test design.

🌍 Real-World Example:

Hard Assert: If the login fails, there's no point checking if the dashboard loads. Soft Assert: If the username is misspelled, we still want to check if the profile picture loaded correctly.

🎯 Scenario-Based Interview Question:

You are testing a checkout page. You want to check the 'User Name' is correct and that the 'Total Price' is correct. Which one should be a Hard Assert?