Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Examples/utilities/screenshot.robot
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ${HOME_PAGE_URL} http://127.0.0.1:7272/basic-html-elements.html
Capture page screenshot
Capture Page Screenshot
Capture Page Screenshot test-{index}.png
Capture Page Screenshot fullPage=True


*** Keywords ***
Expand Down
2 changes: 1 addition & 1 deletion PuppeteerLibrary/ikeywords/iscreenshot_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class iScreenshotAsync(BaseAsyncKeywords, ABC):

@abstractmethod
async def capture_page_screenshot(self, path: str):
async def capture_page_screenshot(self, path: str, fullPage: bool):
pass


6 changes: 4 additions & 2 deletions PuppeteerLibrary/keywords/screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ def get_async_keyword_group(self) -> iScreenshotAsync:
return self.ctx.get_current_library_context().get_async_keyword_group(type(self).__name__)

@keyword
def capture_page_screenshot(self, filename=DEFAULT_FILENAME_PAGE):
def capture_page_screenshot(self, filename=DEFAULT_FILENAME_PAGE, fullPage=False):
"""
Capture current web page as image png file.

The ``filename`` argument specifies filename and path to save the file.
Default valid is 'puppeteer-screenshot-{index}.png'.

The ``fullPage`` argument specifieds capture screenshot as full page.

Example:

Expand All @@ -29,7 +31,7 @@ def capture_page_screenshot(self, filename=DEFAULT_FILENAME_PAGE):

"""
path = self._get_screenshot_path(filename)
self.loop.run_until_complete(self.get_async_keyword_group().capture_page_screenshot(path))
self.loop.run_until_complete(self.get_async_keyword_group().capture_page_screenshot(path, bool(fullPage)))
self._embed_to_log_as_file(path, 800)

def _get_screenshot_path(self, filename):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class PlaywrightScreenshot(iScreenshotAsync):
def __init__(self, library_ctx):
super().__init__(library_ctx)

async def capture_page_screenshot(self, path: str):
async def capture_page_screenshot(self, path: str, fullPage: bool):
return await self.library_ctx.get_current_page().get_page().screenshot(
path=f''+path
path=f''+path,
fullPage=fullPage
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ class PuppeteerScreenshot(iScreenshotAsync):
def __init__(self, library_ctx):
super().__init__(library_ctx)

async def capture_page_screenshot(self, path: str):
async def capture_page_screenshot(self, path: str, fullPage: bool):
return await self.library_ctx.get_current_page().get_page().screenshot(
{'path': path}
{
'path': path,
'fullPage': fullPage
}
)