modify session with selenium

This commit is contained in:
Cayo Puigdefabregas 2021-02-15 21:09:40 +01:00
parent f87ad48b7c
commit 1f57cdb48d
1 changed files with 15 additions and 15 deletions

View File

@ -95,23 +95,23 @@ class BaseLiveServerTestCase(AppDependencyMixin, LiveServerTestCase):
def admin_login(self): def admin_login(self):
# Original option # Original option
session = SessionStore() # session = SessionStore()
session[SESSION_KEY] = self.account.id # session[SESSION_KEY] = self.account.id
session[BACKEND_SESSION_KEY] = settings.AUTHENTICATION_BACKENDS[0] # session[BACKEND_SESSION_KEY] = settings.AUTHENTICATION_BACKENDS[0]
session.save() # session.save()
## to set a cookie we need to first visit the domain. # to set a cookie we need to first visit the domain.
self.selenium.get(self.live_server_url + '/admin/') # self.selenium.get(self.live_server_url + '/admin/')
self.selenium.add_cookie(dict( # self.selenium.add_cookie(dict(
name=settings.SESSION_COOKIE_NAME, # name=settings.SESSION_COOKIE_NAME,
value=session.session_key, # # value=session.session_key,
path='/', # path='/',
)) # ))
# Selenium option # Selenium option
# self.selenium.get(self.live_server_url + '/admin/') self.selenium.get(self.live_server_url + '/admin/')
# self.selenium.find_element_by_id("id_username").send_keys(self.account.username) self.selenium.find_element_by_id("id_username").send_keys(self.account.username)
# self.selenium.find_element_by_id("id_password").send_keys(self.account_password) self.selenium.find_element_by_id("id_password").send_keys(self.account_password)
# self.selenium.find_element_by_css_selector("input[type='submit']").click() self.selenium.find_element_by_css_selector("input[type='submit']").click()
def rest_login(self): def rest_login(self):
self.rest.login(username=self.account.username, password=self.account_password) self.rest.login(username=self.account.username, password=self.account_password)