Skip to content

Commit

Permalink
selenium: add get_screenshot_as_file
Browse files Browse the repository at this point in the history
  • Loading branch information
naisanzaa committed Nov 7, 2023
1 parent 6fd2144 commit cc39278
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions automon/integrations/seleniumWrapper/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,17 +378,32 @@ def get_random_user_agent(self, filter: list or str = None, case_sensitive: bool
return SeleniumUserAgentBuilder().get_random(filter=filter, case_sensitive=case_sensitive)

@_is_running
def get_screenshot_as_png(self, **kwargs):
"""screenshot as png"""
screenshot = self.webdriver.get_screenshot_as_png(**kwargs)
def get_screenshot_as_base64(self, **kwargs):
"""screenshot as base64"""
screenshot = self.webdriver.get_screenshot_as_base64(**kwargs)
log.debug(f'{round(len(screenshot) / 1024)} KB')

return screenshot

def get_screenshot_as_file(
self,
filename: str = None,
prefix: str = None,
folder: str = None,
**kwargs
) -> bool:
return self.save_screenshot(
self,
filename=filename,
prefix=prefix,
folder=folder,
**kwargs
)

@_is_running
def get_screenshot_as_base64(self, **kwargs):
"""screenshot as base64"""
screenshot = self.webdriver.get_screenshot_as_base64(**kwargs)
def get_screenshot_as_png(self, **kwargs):
"""screenshot as png"""
screenshot = self.webdriver.get_screenshot_as_png(**kwargs)
log.debug(f'{round(len(screenshot) / 1024)} KB')

return screenshot
Expand Down

0 comments on commit cc39278

Please sign in to comment.