Skip to content

Commit

Permalink
selenium: fix autosave_cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
naisanzaa committed Oct 1, 2024
1 parent c36c249 commit 1bc0573
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions automon/integrations/seleniumWrapper/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def refresh(self) -> None:

@property
def url(self):
"""alias to current_url"""
return self.current_url

@property
Expand Down Expand Up @@ -367,7 +368,8 @@ def add_cookie_from_url(self, url: str) -> bool:
logger.info(f'add_cookie_from_url :: done')
return add_cookie_from_url

raise Exception(f'add_cookie_from_url :: failed :: {cookie_file=}')
logger.error(f'add_cookie_from_url :: failed :: file not found :: {cookie_file=}')
raise Exception(f'add_cookie_from_url :: failed :: file not found :: {cookie_file=}')

def add_cookie_from_base64(self, base64_str: str) -> bool:
"""add cookie from base64 string"""
Expand All @@ -385,14 +387,16 @@ def add_cookie_from_base64(self, base64_str: str) -> bool:

def autosave_cookies(self) -> bool:
"""auto save cookies for current url"""
logger.debug(f'autosave_cookies')
logger.debug(f'autosave_cookies :: {self.current_url=}')

if self.current_url:
logger.debug(f'autosave_cookies :: {self.current_url=}')

if not self.autosaved:
logger.debug(f'autosave_cookies :: {self.autosaved=}')
self.add_cookie_from_current_url()
try:
self.add_cookie_from_current_url()
except:
logger.debug(f'autosave_cookies :: no cookies for {self.current_url=}')
self.refresh()
self.autosaved = True
logger.debug(f'autosave_cookies :: {self.autosaved=}')
Expand Down

0 comments on commit 1bc0573

Please sign in to comment.