samedi 17 octobre 2015

How to write test cases for Simple Users and Super Users in Django

I want to write test cases in Django to check which user is a simple user, and which is SuperUser and came across this code:

    def test_login_user(self):
        self.selenium.get('%s%s' % (self.live_server_url, '/login/'))
        username_input = self.selenium.find_element_by_name("username")
        username_input.send_keys('testuser')
        password_input = self.selenium.find_element_by_name("password")
        password_input.send_keys('testpass')
        self.selenium.find_element_by_xpath('//button[@type="submit"]').click()
        #password_input.send_keys(Keys.RETURN)

    def test_login_staff(self):
        self.selenium.get('%s%s' % (self.live_server_url, '/login/'))
        username_input = self.selenium.find_element_by_name("username")
        username_input.send_keys('testadmin')
        password_input = self.selenium.find_element_by_name("password")
        password_input.send_keys('testpass')

I code is running fine in my project but my question is how you return False here, when we enter some invalid login credentials. Currently, even if I pass some invalid username and password, it is not showing anything.

Aucun commentaire:

Enregistrer un commentaire