import unittest from selenium import webdriver from selenium.webdriver.common.keys import Keys class JPythonSearch(unittest.TestCase): def setUp(self): self.driver = webdriver.Firefox() def test_search_in_python_org(self): URL = "http://jpython.blogspot.com" driver = self.driver driver.get(URL) self.assertIn("Life is very easy with Python", driver.title) elem = driver.find_element_by_name("q") elem.send_keys("BFS") elem.send_keys(Keys.RETURN) assert "No results found." not in driver.page_source def tearDown(self): self.driver.close() if __name__ == "__main__": unittest.main()
Output:
. ---------------------------------------------------------------------- Ran 1 test in 25.592s OK [Finished in 25.7s]
0 comments:
Post a Comment