Created
April 24, 2012 20:01
-
-
Save bennylope/2483172 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.test import LiveServerTestCase | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.firefox.webdriver import WebDriver | |
class MySeleniumTests(LiveServerTestCase): | |
@classmethod | |
def setUpClass(cls): | |
cls.selenium = WebDriver() | |
super(MySeleniumTests, cls).setUpClass() | |
@classmethod | |
def tearDownClass(cls): | |
super(MySeleniumTests, cls).tearDownClass() | |
cls.selenium.quit() | |
def test_form(self): | |
self.selenium.get('%s%s' % (self.live_server_url, '/')) | |
username = self.selenium.find_element_by_name('username') | |
username.send_keys('bennylope') | |
self.selenium.find_element_by_name('submit').click() | |
def test_form_validation(self): | |
"""Validate the form with JavaScript""" | |
self.selenium.get('%s%s' % (self.live_server_url, '/')) | |
first_name = self.selenium.find_element_by_name('first_name') | |
first_name.send_keys('ben') | |
last_name = self.selenium.find_element_by_name('last_name') | |
last_name.send_keys('lopatin') | |
self.selenium.find_elements(By.XPATH, "//input[@value='benlopatin']") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment