Common Assertions
- Assertlocation (judging the current is on the right page)
- Asserttitle (check that the title of the current page is correct)
- Assertvalue (check input value, checkbox or radio, with value "on" inaction "off")
- assertselected (check if select is correct in the dropdown menu)
- Assertselectedoptions (check whether the options in the drop-down menu are correct)
- Asserttext (checks the text of the specified element)
- Asserttextpresent (checks if the specified text appears on the page currently displayed to the user)
- Asserttextnotpresent (checks if the specified text does not appear on the page currently displayed to the user)
- Assertattribute (checks the value of the property of the currently specified element)
- Asserttable (check the value in a cell in the table)
- Asserteditable (checks whether the specified input can be edited)
- Assertnoteditable (checks whether the specified input cannot be edited)
- Assertalert (check if there is an alert dialog box with the specified message)
- Verifytitle (check the expected page title)
- Verifytextpresent (Verify that the expected text is somewhere on the page)
- Verifyelementpresent (validates the expected UI element, its definition of the HTML tag, whether it is on the current page)
- Verifytext (Verify that both the expected text and the corresponding HTML tags are present on the page)
- Verifytable (Verify the expected contents of the table)
- Waitforpagetoload (pause execution until the expected new page loads)
- Waitforelementpresent (waits for an element to be checked for existence.) Is true, it is executed)
Exception type
- Assertionerror:assert statement failed
- Attributeerror: Attempting to access an object that does not have a property
- IOError: Input and output exception, basically cannot open file
- Importerror: Unable to introduce module or package, basically a path problem
- Indentationerror: syntax error, code not aligned correctly
- Indexerror: Subscript index out of sequence boundary
- Keyerror: Attempting to access a key that does not exist in the dictionary
- The keyboadrinterrupt:ctrl+c was pressed
- Nameerror: Using a variable that has not yet been assigned to a value object
- Syntaxerror:python code Logic syntax error, cannot execute
- TypeError: Incoming object type does not match the requirements
- Unboundlocalerror: Attempting to access a global variable that has not yet been set is basically due to another global variable with the same name, causing you to think that you are accessing
- ValueError: Pass in a value that is not expected, even if the type is correct
Assertions in the UnitTest framework
(in the UnitTest Unit test framework, the TestCase class provides methods to check for and report a failure)
Python+selenium+unitest Framework Assertion Method Detailed tutorial