python - Authentication failed in Django test -
in django tried create user , tried login user using selenium , when run test failed , showing authentication error. here code :
class loginfunctionaltest(unittest.testcase): def setup(self): self.browser = webdriver.firefox() self.browser.implicitly_wait(3) # self.browser.get('http://localhost:8000') def teardown(self): self.browser.quit() def test_login_page(self): self.browser.get('http://localhost:8000') self.assertin('hiren->login', self.browser.title) def test_login_form(self): self.browser.get('http://localhost:8000') user = user.objects.create_user('testhiren', 'myemail@test.com', 'testpass') user.save() username = self.browser.find_element_by_id('username-id') password = self.browser.find_element_by_id('password-id') submit = self.browser.find_element_by_id('login-button') username.send_keys('testhiren') password.send_keys('testpass') submit.click() time.sleep(10) # if authentication successful redirects /dashboard location = self.browser.current_url self.assertequal('http://localhost:8000/dashboard', location)
any idea why failing ?
so figured out fn test using default database rather test database, changed flow
Comments
Post a Comment