Course Content
Selenium Python First Script
Selenium Python First Script
0/2
HTML Form elements
HTML Form elements
0/1
Handle HTML Frames
Handle HTML Frames
0/2
Handling Dropdown Lists
Handling Dropdown Lists
0/2
Selenium Action class
Selenium Action class
0/1
Selenium Python for Beginners [ 2024 ]
About Lesson

PyUnit Assertions

Assertion commands check and validate a given condition’s result, whether True or False.

Some of the most commonly used assertions are as follows in table format:  

Assertion Description
 assertTrue(x) This method returns True if bool(x) is True
 assertFalse(x) This method returns True if bool(x) is False
 assertEqual(a, b) This method returns True if a == b
 assertNotEqual(a,b) This method returns True if a != b
 assertIn(a,b) This method returns True if a is in b
 assertNotIn(a,b) This method returns True if a is not in b
 assertGreater(a,b) This method returns True if a > b
 assertGreaterEqual(a,b) This method returns True if a >= b
 assertLess(a,b) This method returns True if a < b
 assertLessEqual(a,b) This method returns True if a <= b

 

To get the full list use the Eclipse IDE.

 

PyUnit Assertions EclipseIDE

 

Assert statements mark the test as pass or fail depending on the expected conditions and actual results during the test run.

Failed assertions will throw : AssertionError

Join the conversation