From 1bc0573ed554b6cb7d79b16f4d225e50c4de876c Mon Sep 17 00:00:00 2001 From: naisanzaa Date: Sat, 28 Sep 2024 04:04:39 +0800 Subject: [PATCH] selenium: fix autosave_cookies --- automon/integrations/seleniumWrapper/browser.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/automon/integrations/seleniumWrapper/browser.py b/automon/integrations/seleniumWrapper/browser.py index 11fe9159..64423d74 100644 --- a/automon/integrations/seleniumWrapper/browser.py +++ b/automon/integrations/seleniumWrapper/browser.py @@ -169,6 +169,7 @@ def refresh(self) -> None: @property def url(self): + """alias to current_url""" return self.current_url @property @@ -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""" @@ -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=}')