Selenium RC For Python: tutorial 3

Source: Internet
Author: User

1. Check the title

Code Def test_navigate_page_without_click_link (self ):
Sel = self. selenium
Sel. open (self. BASE_URL)
Sel. open (self. TEST_PAGE_URL)
Self. assertEquals (self. TEST_PAGE_TITLE, sel. get_title ())

Def test_navigate_page_click_link (self ):
Sel = self. selenium
Sel. open (self. BASE_URL)
Sel. click ("link = Test Page For Selenium Remote Control ")
Sel. wait_for_page_to_load (self. MAX_WAIT_IN_MS)
Self. assertEquals (self. TEST_PAGE_TITLE, sel. get_title ())

2. verify the existence of elements

Code Def test_is_element_exists (self ):
Sel = self. selenium
Sel. open (self. TEST_PAGE_URL)
Sel. wait_for_page_to_load (self. MAX_WAIT_IN_MS)
Self. assertTrue (sel. is_element_present ("id = textInput "))

3. text input

Enter the content in the text box and use get_value to check the value obtained in the text box.

 

Code Def test_enter_values_into_textfield_checkwithgetvalue (self ):
Sel = self. selenium
Sel. open (self. TEST_PAGE_URL)
Sel. wait_for_page_to_load (self. MAX_WAIT_IN_MS)
Self. assertEquals ("", sel. get_value ("id = textInput "))
Sel. type ("id = textInput", "Text In The Field ")
Self. assertEquals ("Text In The Field", sel. get_value ("id = textInput "))

If we use get_text to check the input content, in this example, the text we are interested in is actually the input value. Since the input element does not contain any text, the get_text method returns an empty string.

Code Def test_enter_values_into_textfield_checkwithgettext (self ):
Sel = self. selenium
Sel. open (self. TEST_PAGE_URL)
Sel. wait_for_page_to_load (self. MAX_WAIT_IN_MS)
Self. assertEquals ("", sel. get_text ("id = textInput "))
Sel. type ("id = textInput", "Text In The Field ")
Self. assertEquals ("Text In The Field", sel. get_text ("id = textInput "))

 

 

 

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.