Hey Suraj, there are two types of Assertion in Selenium Webdriver:
-
Hard Assertion: Hard Assertion is an Assertion that throws the AssertException when the test case is failed. In the case of Hard Assertion, you can handle the error by using a catch block like a java exception. Suppose we have two test cases in a suite. The first test case in a suite has an assertion that fails, and if we want to run the second case in a suit, then we need to handle the assertion error.
-
Soft Assertion: To deal with the disadvantage of Hard Assertions, customized error handler provided by TestNG is called Soft Assertion. Soft Assertions are the type of assertions that do not throw an exception when an assertion fails and would continue with the next step after assert statement. This is usually used when our test requires multiple assertions to be executed and the user want all of the assertions/codes to be executed before failing/skipping the tests.