Skip to content

Commit 4cabdef

Browse files
committed
feat: add method to retrieve screenshot as base64 encoded string
1 parent e9f81bf commit 4cabdef

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pydoll/browser/page.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,18 @@ async def get_screenshot(self, path: str):
246246
async with aiofiles.open(path, 'wb') as file:
247247
await file.write(screenshot_bytes)
248248

249+
async def get_screenshot_base64(self):
250+
"""
251+
Retrieves the screenshot of the page as a base64 encoded string.
252+
253+
Returns:
254+
str: The base64 encoded screenshot.
255+
256+
# TODO: remove the duplicated logic
257+
"""
258+
response = await self._execute_command(PageCommands.screenshot())
259+
return response['result']['data'].encode('utf-8')
260+
249261
async def set_download_path(self, path: str):
250262
"""
251263
Sets the download path for the page.

0 commit comments

Comments
 (0)