Skip to content

Instantly share code, notes, and snippets.

@baijum
Created June 25, 2011 11:13
Show Gist options
  • Save baijum/1046377 to your computer and use it in GitHub Desktop.
Save baijum/1046377 to your computer and use it in GitHub Desktop.
Selenium TestCase using Python binding
import unittest
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
class PythonOrgSearch(unittest.TestCase):
def setUp(self):
self.browser = webdriver.Firefox()
def test_search_in_python_org(self):
browser = self.browser
browser.get("http://www.python.org")
assert "Python" in browser.title
time.sleep(2)
elem = browser.find_element_by_name("q")
elem.send_keys("selenium")
elem.send_keys(Keys.RETURN)
assert "Google" in browser.title
def tearDown(self):
self.browser.close()
if __name__ == "__main__":
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment