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 "))