def setUp(self): log("Starting test: " + unittest.TestCase.id(self)) self.samuranium = Core() self.url = "http://www.python.org" self.samuranium.set_browser_type('Firefox') self.samuranium.go_to_url(self.url)
class PythonOrgSearch(unittest.TestCase): def setUp(self): log("Starting test: " + unittest.TestCase.id(self)) self.samuranium = Core() self.url = "http://www.python.org" self.samuranium.set_browser_type('Firefox') self.samuranium.go_to_url(self.url) def test_search_in_python_org(self): assert self.samuranium.select_element_by_id("id-search-field") assert self.samuranium.type("Python") assert self.samuranium.submit() assert self.samuranium.reset_current_element() assert self.samuranium.build_element_list_by_tag_name("a") assert self.samuranium.select_element_from_list_by_index(2) log(self.samuranium.get_text()) def test_help_documentation_in_python_org(self): assert self.samuranium.select_element_by_id("about") assert self.samuranium.hover() assert self.samuranium.reset_current_element() assert self.samuranium.wait_for_element_to_be_displayed_by_css_selector("#about [href='/about/help/']") assert self.samuranium.select_element_by_css_selector("#about [href='/about/help/']") assert self.samuranium.click() assert self.samuranium.reset_current_element() assert self.samuranium.wait_for_element_to_be_displayed_by_css_selector( "[href='http://wiki.python.org/moin/BeginnersGuide']") assert self.samuranium.select_element_by_css_selector("[href='http://wiki.python.org/moin/BeginnersGuide']") assert self.samuranium.click() assert self.samuranium.wait_for_element_to_be_displayed_by_css_selector("[id='Beginner.27s_Guide_to_Python']") assert self.samuranium.reset_current_element() assert self.samuranium.select_element_by_css_selector("[id='Beginner.27s_Guide_to_Python']") assert "Beginner's Guide to Python" in self.samuranium.get_text() assert self.samuranium.reset_current_element() assert self.samuranium.select_element_by_link_text("list of Non-English resources") assert self.samuranium.click() assert self.samuranium.reset_current_element() assert self.samuranium.wait_for_element_to_be_displayed_by_partial_link_text("Spanish") assert self.samuranium.select_element_by_partial_link_text("Spanish") log("Selected language: " + self.samuranium.get_text()) assert self.samuranium.click() assert self.samuranium.reset_current_element() assert self.samuranium.select_element_by_class_name("backlink") assert "Spanish" in self.samuranium.get_text() log("Selected language: " + self.samuranium.get_text()) assert self.samuranium.take_screenshot("screenshot") def tearDown(self): self.samuranium.close()