# What is the difference between Assert and Verify in Selenium?

Software TestingAutomation TestingSelenium Web Driver

The differences between Assert and Verify are listed below −

sl.no.Assert
Verify
1Verifies if the specified condition is true and false. If the result is true, the next test step will be executed. In case of false condition, the execution would terminate.
Verifies if the specified condition is true and false. If the result is true, the next test step will be executed. In case of false condition, the execution would still continue.
2In case of false condition, the next text case of the suite will be executed.
In case of false condition, the next test step of the same text case will continue.
3There are two types of assets namely hard and soft asserts.
There are no categories for verification.

Thus we see there two types of Asserts.

The difference between Soft Assert vs Hard Assert are listed below −

sl.no.Hard Assert
Soft Assert
1Throws an exception immediately after the assert fails and carries out with the next test case of the suite.
Does not throw an exception immediately when the assertion fails, collects them and carries out with the next validation.
2This throws an AssertException instantly so handled with a catch block. After suite execution is completed the test is made as PASS.
This accumulates the errors in each @Test execution.

Object creation for Hard and Soft Assertion.

Assertion HAssert = new Assertion();
SoftAssert SAssert = new SoftAssert();

Soft Assert Examples

SAssert.assertTrue(false);
SAssert.assertEquals("Tutorialspoint", "Tutorial");

Hard Assert Examples

HAssert.assertNotEquals("Tutorialspoint", "Tutorial");
HAssert.assertTrue(false);
Published on 10-Jun-2020 12:31:31