Explain Assertion in selenium
Question
Explain Assertion in selenium
Answer
Below are the methods for Assertion in selenium
AssertEquals : AssertEquals() is a method used to compare the actual and expected results. If both the actual and expected results are same, then the assertion pass with no exception and the test case is marked as “passed”. If both the actual and expected results are not the same, then the assertion fails with an exception and the test case is marked as “failed”
Syntax: Assert.assertEquals(actual,expected);
AssertNotEquals: It is a method used to compare the actual and expected results. If both the actual and expected results are not the same, then the assertion pass with no exception and the test case is marked as “passed”. If both the actual and expected results are same, then the assertion fails with an exception and the test case is marked as “failed”
Syntax: AssertNotEquals(actual,expected,message);Â
AssertTrue- Assertion verifies the boolean value returned by a condition. If the boolean value is true, then assertion passes the test case, and if the boolean value is false, then assertion aborts the test case by an exception
Syntax: Assert.AssertTrue(condition);
AssertFalse-Assertion verifies the boolean value returned by a condition. If the boolean value is false, then assertion passes the test case, and if the boolean value is true, then assertion aborts the test case by an exception.
Syntax: Assert.AssertFalse(condition);
Â
AssertNull: It is a method that verifies whether the object is null or not. If an object is null, then assertion passes the test case otherwise it marks as failed
Syntax: Assert.assertNull(object);
AssertNotNull-It is a method that verifies whether the object is null or not. If an object is not null, then assertion passes otherwise it marks as failed
Syntax: Assert.assertNotNull(object);Â Â