Python+selenium+unitest Framework Assertion Method Detailed tutorial

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.