5
Django StaticLiveServerTestCase: Anonymous Sessions
source link: https://snakeycode.wordpress.com/2020/12/02/django-staticliveservertestcase-anonymous-sessions/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Django StaticLiveServerTestCase: Anonymous Sessions
I had a Django webpage that I wanted to test using selenium. That page used values from request.session and the user was anonymous. Here is how I setup the session (based on https://stackoverflow.com/a/57113280/418798):
session = self.client.session
session[key] = value
session.save()
self.selenium.add_cookie(
{'name': 'sessionid', 'value': session._SessionBase__session_key, 'secure': False, 'path': '/'}
)
Post navigation
Leave a Reply Cancel reply
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK