2

How do you disable CSRF for live server tests in Django when using Selenium?

Any page the browser tries to visit with Selenium throws a CSRF failure. I've tried modifying my settings to remove django.middleware.csrf.CsrfViewMiddleware from my MIDDLEWARE_CLASSES and setting CSRF_COOKIE_DOMAIN to self.live_server_url but those had no effect.

Unfortunately, enforce_csrf_checks doesn't seem to be supported when using Selenium.

Cerin
  • 60,957
  • 96
  • 316
  • 522
  • Do you mean when submitting forms? Or when simply visiting a page? – DaveBensonPhillips Mar 28 '16 at 21:31
  • You can try to get the CSRF code and use it within your unittest. I'm doing that here http://stackoverflow.com/questions/37017587/cant-test-password-change-in-django-unittest – Ahmed May 04 '16 at 03:09

0 Answers0