Assertions and Validation

Soft Vs Hard Validation

Learning Outcome

5

Choose the right validation strategy for real-world automation

4

Understand the execution flow of both approaches

3

Identify when to use each validation type

2

Differentiate between Hard and Soft Validation.

1

Explain Validation in Playwright

Imagine passengers entering an airport

Every passenger must pass through security before boarding

Passenger A

Security finds a prohibited item

The passenger is immediately stopped

They cannot proceed further

Passenger A

Passenger B

A quality inspector is checking the airport facilities:

Display boards

Seating area

Washrooms

Food court

Security gates

Soft Validation behaves like a quality inspection. it continues checking everything and reports all failures together at the end.

Hard Validation behaves like airport security. it immediately stops further execution when a critical problem is detected.

What is Hard Validation?

Hard Validation immediately stops test execution when a validation fails

If one assertion fails:

Current test stops

Remaining steps are skipped

Test is marked as Failed.

assertThat(page).hasTitle("OrangeHRM");

Best Used For

What is Soft Validation?

Soft Validation continues test execution even if one or more validations fail.

All validations are executed

All failures are collected and reported together at the end

Playwright Java does not provide built-in Soft Assertions. A common approach is to use TestNG's SoftAssert

Hard Validation vs Soft Validation

Practical Scenario

Login Test (Hard Validation)

Login

Verify Dashboard

Stop if Dashboard verification fails

Dashboard Validation (Soft Validation)

Logo

Username

Welcome Message

Search Box

Notification Icon

Best Practice

Use Hard Validation for business-critical workflows

Use Soft Validation when validating multiple independent UI elements

Always call assertAll() when using SoftAssert; otherwise, failures are not reported

Choose the validation type based on the test objective, not personal preference

Summary

5

TestNG SoftAssert is commonly used for Soft Validation

4

Playwright Java supports Hard Assertions by default

3

Continues and reports all failures

2

Hard Validation stops execution immediately on failure

1

Validation compares expected and actual results

Quiz

Playwright Java supports which assertion type by default?

A. Soft Assertion

B. Hard Assertion

C. Dynamic Assertion

D. Conditional Assertion

Quiz-Answer

Playwright Java supports which assertion type by default?

A. Soft Assertion

B. Hard Assertion

C. Dynamic Assertion

D. Conditional Assertion

Soft Vs Hard Validation

By Content ITV

Soft Vs Hard Validation

  • 181