class Login(unittest.TestCase):

    def setUp(self):
        self.driver = webdriver.Firefox()

def tearDown(self):
    self.driver.quit()

def test_login(self):
    driver = self.driver
driver.get('http://testurl')
username = driver.find_element_by_name('user_id')
username.send_keys('admin')
Selenium Webdriver example in Python