Skip to content

Commit

Permalink
selenium: update logger strings in chrome webdriver
Browse files Browse the repository at this point in the history
  • Loading branch information
naisanzaa committed Oct 9, 2024
1 parent 1cee1c5 commit 107fb78
Showing 1 changed file with 30 additions and 24 deletions.
54 changes: 30 additions & 24 deletions automon/integrations/seleniumWrapper/webdriver_chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@ def disable_notifications(self):
"prefs", {"profile.default_content_setting_values.notifications": 2}
)

logger.debug(str(dict(
add_experimental_option=("prefs", {"profile.default_content_setting_values.notifications": 2})
)))
logger.debug(
f'webdriver :: chrome :: '
f'disable_notifications :: '
f'{dict(name="prefs", value={"profile.default_content_setting_values.notifications": 2})}'
)

return self

def disable_sandbox(self):
Expand Down Expand Up @@ -148,9 +151,12 @@ def enable_notifications(self):
self.chrome_options.add_experimental_option(
"prefs", {"profile.default_content_setting_values.notifications": 1}
)
logger.debug(str(dict(
add_experimental_option=("prefs", {"profile.default_content_setting_values.notifications": 1})
)))
logger.debug(
f'webdriver :: chrome :: '
f'enable_notifications :: '
f'{dict(name="prefs", value={"profile.default_content_setting_values.notifications": 1})}'
)

return self

def enable_maximized(self):
Expand All @@ -168,20 +174,20 @@ def enable_translate(self, native_language: str = 'en'):
value=prefs,
)

logger.debug(str(dict(
add_experimental_option=dict(
name="prefs",
value=prefs,
)
)))
logger.debug(
f'webdriver :: chrome :: '
f'enable_translate :: '
f'{dict(name="prefs", value=prefs)}'
)

return self

def close(self):
"""close
"""
result = self.webdriver.close()
logger.info(f'{result}')
logger.info(f'webdriver :: chrome :: close :: {result}')
return result

def in_docker(self):
Expand Down Expand Up @@ -339,12 +345,12 @@ def set_locale_experimental(self, locale: str = 'en-US'):
value={'intl.accept_languages': locale}
)

logger.debug(str(dict(
add_experimental_option=dict(
name='prefs',
value={'intl.accept_languages': locale}
)
)))
logger.debug(
f'webdriver :: chrome :: '
f'add_experimental_option :: '
f'{dict(name='prefs', value={'intl.accept_languages': locale})}'
)

return self

def set_user_agent(self, user_agent: str):
Expand Down Expand Up @@ -384,20 +390,20 @@ def update_paths(self, path: str):
os.environ['PATH'] = f"{os.getenv('PATH')}:{path}"

# logger.debug(f'update_paths :: {path=} :: {os.environ['PATH']}')
logger.debug(f'update_paths :: {path}')
logger.debug(f'webdriver :: chrome :: update_paths :: {path}')

logger.info(f'update_paths :: done')
logger.info(f'webdriver :: chrome :: update_paths :: done')
return True

logger.error(f'update_paths :: failed :: {path} not found')
logger.error(f'webdriver :: chrome :: update_paths :: failed :: {path} not found')
return False

def quit(self):
"""quit
"""
result = self.webdriver.quit()
logger.info(f'{result}')
logger.info(f'webdriver :: chrome :: quit :: {result}')
return result

def quit_gracefully(self):
Expand All @@ -409,6 +415,6 @@ def quit_gracefully(self):
self.quit()
self.stop_client()
except Exception as error:
logger.error(f'failed to gracefully quit. {error}')
logger.error(f'webdriver :: chrome :: quit :: error :: failed to gracefully quit. {error}')
return False
return True

0 comments on commit 107fb78

Please sign in to comment.