python tests/unittest/test_SeleniumUnittest.py
test_page_title (__main__.GoogleTestCase)
Assert that title of page says 'Google'. ... ok
test_search_page_title (__main__.GoogleTestCase)
Assert that Google search returns data for 'Red Hat'. ... ok
----------------------------------------------------------------------
Ran 2 tests in 7.765s
OK
import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
class PythonOrgSearch(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
def test_search_in_python_org(self):
driver = self.driver
driver.get("http://www.python.org")
self.assertIn("Python", driver.title)
elem = driver.find_element(By.NAME, "q")
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
self.assertNotIn("No results found.", driver.page_source)
def tearDown(self):
self.driver.close()
if __name__ == "__main__":
unittest.main()