In the previous sections, we saw various find_element_by
methods along with examples. Let's pull together all these examples in a test.
Create a new
homepagetest.py
file and copy all the tests that we created earlier as shown in the following code:import unittest from selenium import webdriver class HomePageTest(unittest.TestCase): @classmethod def setUpClass(cls): # create a new Firefox session cls.driver = webdriver.Firefox() cls.driver.implicitly_wait(30) cls.driver.maximize_window() # navigate to the application home page cls.driver.get('http://demo.magentocommerce.com/') def test_search_text_field_max_length(self): # get the search textbox search_field = self.driver.find_element_by_id("search") # check maxlength attribute is set to 128 self.assertEqual("128", search_field.get_attribute ("maxlength")) def test_search_button_enabled(self...