Skip to content

Commit 8471ef1

Browse files
committed
Update cookie methods that use "expiry"
1 parent 98f5f9d commit 8471ef1

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4592,9 +4592,9 @@ def load_cookies(self, name="cookies.txt", expiry=False):
45924592
Loads the page cookies from the "saved_cookies" folder.
45934593
Usage for setting expiry:
45944594
If expiry == 0 or False: Delete "expiry".
4595+
If expiry is True: Set "expiry" to 24 hours in the future.
45954596
If expiry == -1 (or < 0): Do not modify "expiry".
45964597
If expiry > 0: Set "expiry" to expiry minutes in the future.
4597-
If expiry == True: Set "expiry" to 24 hours in the future.
45984598
"""
45994599
cookies = self.get_saved_cookies(name)
46004600
self.wait_for_ready_state_complete()
@@ -4606,12 +4606,12 @@ def load_cookies(self, name="cookies.txt", expiry=False):
46064606
cookie["domain"] = trim_origin
46074607
if "expiry" in cookie and (not expiry or expiry == 0):
46084608
del cookie["expiry"]
4609+
elif expiry is True:
4610+
cookie["expiry"] = int(time.time()) + 86400
46094611
elif isinstance(expiry, (int, float)) and expiry < 0:
46104612
pass
46114613
elif isinstance(expiry, (int, float)) and expiry > 0:
46124614
cookie["expiry"] = int(time.time()) + int(expiry * 60.0)
4613-
elif expiry:
4614-
cookie["expiry"] = int(time.time()) + 86400
46154615
self.driver.add_cookie(cookie)
46164616

46174617
def delete_all_cookies(self):
@@ -4693,9 +4693,9 @@ def add_cookie(self, cookie_dict, expiry=False):
46934693
self.add_cookie({'name': 'foo', 'value': 'bar', 'sameSite': 'Strict'})
46944694
Usage for setting expiry:
46954695
If expiry == 0 or False: Delete "expiry".
4696+
If expiry is True: Set "expiry" to 24 hours in the future.
46964697
If expiry == -1 (or < 0): Do not modify "expiry".
46974698
If expiry > 0: Set "expiry" to expiry minutes in the future.
4698-
If expiry == True: Set "expiry" to 24 hours in the future.
46994699
"""
47004700
self.__check_scope()
47014701
self._check_browser()
@@ -4707,21 +4707,21 @@ def add_cookie(self, cookie_dict, expiry=False):
47074707
cookie["domain"] = trim_origin
47084708
if "expiry" in cookie and (not expiry or expiry == 0):
47094709
del cookie["expiry"]
4710+
elif expiry is True:
4711+
cookie["expiry"] = int(time.time()) + 86400
47104712
elif isinstance(expiry, (int, float)) and expiry < 0:
47114713
pass
47124714
elif isinstance(expiry, (int, float)) and expiry > 0:
47134715
cookie["expiry"] = int(time.time()) + int(expiry * 60.0)
4714-
elif expiry:
4715-
cookie["expiry"] = int(time.time()) + 86400
47164716
self.driver.add_cookie(cookie_dict)
47174717

47184718
def add_cookies(self, cookies, expiry=False):
47194719
"""
47204720
Usage for setting expiry:
47214721
If expiry == 0 or False: Delete "expiry".
4722+
If expiry is True: Set "expiry" to 24 hours in the future.
47224723
If expiry == -1 (or < 0): Do not modify "expiry".
47234724
If expiry > 0: Set "expiry" to expiry minutes in the future.
4724-
If expiry == True: Set "expiry" to 24 hours in the future.
47254725
"""
47264726
self.__check_scope()
47274727
self._check_browser()
@@ -4733,12 +4733,12 @@ def add_cookies(self, cookies, expiry=False):
47334733
cookie["domain"] = trim_origin
47344734
if "expiry" in cookie and (not expiry or expiry == 0):
47354735
del cookie["expiry"]
4736+
elif expiry is True:
4737+
cookie["expiry"] = int(time.time()) + 86400
47364738
elif isinstance(expiry, (int, float)) and expiry < 0:
47374739
pass
47384740
elif isinstance(expiry, (int, float)) and expiry > 0:
47394741
cookie["expiry"] = int(time.time()) + int(expiry * 60.0)
4740-
elif expiry:
4741-
cookie["expiry"] = int(time.time()) + 86400
47424742
self.driver.add_cookie(cookie)
47434743

47444744
def __set_esc_skip(self):

0 commit comments

Comments
 (0)