I am trying to create a test for checking in the user has successfully log in or not. But I am having troubles to check once the user fulfills the log in form if it appears as authenticated or not.
I try to wait 10 s to leave time to Django to do the request , but I don't manage
My actual test is
class MySeleniumTests(StaticLiveServerTestCase):
@classmethod
def setUpClass(cls):
super(MySeleniumTests, cls).setUpClass()
cls.driver = WebDriver()
def setUp(self):
pass
@classmethod
def tearDownClass(cls):
cls.driver.quit()
super(MySeleniumTests, cls).tearDownClass()
def test_login(self):
driver = self.driver
user = auth.get_user(self.client)
self.assertFalse(user.is_authenticated)
user = User.objects.create_user(username="testuser", password="testuser")
driver.get("http://127.0.0.1:8000/cuentas/login/")
driver.find_element_by_id("id_login").click()
driver.find_element_by_id("id_login").clear()
driver.find_element_by_id("id_login").send_keys("testuser")
driver.find_element_by_id("id_password").clear()
driver.find_element_by_id("id_password").send_keys("testuser")
driver.find_element_by_id("login-btn").click()
self.driver.implicitly_wait(10)
is_a = auth.get_user(self.client).is_authenticated #<-Problem here
self.assertTrue(is_a)
self.driver.implicitly_wait(10)
driver.get("http://127.0.0.1:8000/")
Aucun commentaire:
Enregistrer un commentaire