@Vinay, JUnit provide these assertions to write Selenium Scripts:
1. assertEquals: Checks if the two values are equal and assertion fails if both values are not equal. This compares Boolean, int, String, float, long, char etc.
Syntax:
Assert.assertEqual(“excepted value”, ”actual value”);
Example:
Assert.assertEqual(“ABC”,”ABC”); // Assertion will pass.
2. assertTrue: Returns true if the condition is true and assertion fails if the condition is false.
Syntax:
Assert.assertTrue(“message”, condition);
Example:
Assert.assertTrue(“Both the strings are not equal”, (“HelloWorld”).equals(“HelloWorld”));
Here assertion will pass as both the strings match. It will print the message if the assertion fails.
3. JUnit assertFalse: Returns true if the condition is false and assertion fails if the condition is true.
Syntax:
Assert.assertFalse(“message”, condition);
Example:
Assert.assertFalse(“Both the strings are equal”, (“Hello”).equals(“HelloWorld”));
There will not be any assertion error as the condition is false.