$ ./manage.py test
我尝试运行此命令:
from django.test import LiveServerTestCase
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
def views_login_user():
pass
def test_login():
views_login_user()
class LoginTestCase(LiveServerTestCase):
def setUp(self):
self.selenium = webdriver.Firefox()
super(LoginTestCase, self).setUp()
def tearDown(self):
self.selenium.quit()
super(LoginTestCase, self).tearDown()
def test_register(self):
selenium = self.selenium
#Opening the link we want to test
selenium.get('http://127.0.0.1:8000/login/register/')
#find the form element
username = selenium.find_element_by_id('id_username')
email_address= selenium.find_element_by_id('id_email_address')
password = selenium.find_element_by_id('id_password')
submit = selenium.find_element_by_name('register')
#Fill the form with data
username.send_keys('gouthami')
email_address.send_keys('gouth@gmail.com')
password.send_keys('gouthu')
#submitting the form
submit.send_keys(Keys.RETURN)
#check the returned result
assert 'Check your email' in selenium.page_source
以下是我的test.py:
failed.txt