Want to be able to test login in a functional test with selenium.
views.py:
def login_view(request, *args, **kwargs):
if request.method == 'POST':
if not request.POST.get('remember_me', None):
request.session.set_expiry(0)
return auth_views.login(request, *args, **kwargs)
functional_tests.py:
class SomeTestCase(unittest.TestCase):
def setUp(self):
self.browser = webdriver.Firefox()
def test1(self):
self.browser.get("http://ift.tt/1NVhBji")
username = self.browser.find_element_by_id("id_username")
password = self.browser.find_element_by_id("id_password")
username.send_keys(USER['username'])
password.send_keys(USER['password'])
self.browser.find_element_by_name("login").click()
# should now be on the right page
self.browser.get('http://ift.tt/1rjq8If')
logout_link_text = self.browser.find_element(By.PARTIAL_LINK_TEXT,"Logout")
self.assertisNotNone(logout_link_text)
Fails. Manually it logs in and redirects to the loggedin_only page properly. Have also tried an implicit wait.
Is there a good way of testing the redirect?
Aucun commentaire:
Enregistrer un commentaire