Skip to content

Commit dc679e1

Browse files
authored
Add support full page screenshot option (#58)
1 parent 9149535 commit dc679e1

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

Examples/utilities/screenshot.robot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ ${HOME_PAGE_URL} http://127.0.0.1:7272/basic-html-elements.html
1313
Capture page screenshot
1414
Capture Page Screenshot
1515
Capture Page Screenshot test-{index}.png
16+
Capture Page Screenshot fullPage=True
1617

1718

1819
*** Keywords ***

PuppeteerLibrary/ikeywords/iscreenshot_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class iScreenshotAsync(BaseAsyncKeywords, ABC):
77

88
@abstractmethod
9-
async def capture_page_screenshot(self, path: str):
9+
async def capture_page_screenshot(self, path: str, fullPage: bool):
1010
pass
1111

1212

PuppeteerLibrary/keywords/screenshot.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ def get_async_keyword_group(self) -> iScreenshotAsync:
1515
return self.ctx.get_current_library_context().get_async_keyword_group(type(self).__name__)
1616

1717
@keyword
18-
def capture_page_screenshot(self, filename=DEFAULT_FILENAME_PAGE):
18+
def capture_page_screenshot(self, filename=DEFAULT_FILENAME_PAGE, fullPage=False):
1919
"""
2020
Capture current web page as image png file.
2121
2222
The ``filename`` argument specifies filename and path to save the file.
2323
Default valid is 'puppeteer-screenshot-{index}.png'.
24+
25+
The ``fullPage`` argument specifieds capture screenshot as full page.
2426
2527
Example:
2628
@@ -29,7 +31,7 @@ def capture_page_screenshot(self, filename=DEFAULT_FILENAME_PAGE):
2931
3032
"""
3133
path = self._get_screenshot_path(filename)
32-
self.loop.run_until_complete(self.get_async_keyword_group().capture_page_screenshot(path))
34+
self.loop.run_until_complete(self.get_async_keyword_group().capture_page_screenshot(path, bool(fullPage)))
3335
self._embed_to_log_as_file(path, 800)
3436

3537
def _get_screenshot_path(self, filename):

PuppeteerLibrary/playwright/async_keywords/playwright_screenshot.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ class PlaywrightScreenshot(iScreenshotAsync):
77
def __init__(self, library_ctx):
88
super().__init__(library_ctx)
99

10-
async def capture_page_screenshot(self, path: str):
10+
async def capture_page_screenshot(self, path: str, fullPage: bool):
1111
return await self.library_ctx.get_current_page().get_page().screenshot(
12-
path=f''+path
12+
path=f''+path,
13+
fullPage=fullPage
1314
)

PuppeteerLibrary/puppeteer/async_keywords/puppeteer_screenshot.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ class PuppeteerScreenshot(iScreenshotAsync):
66
def __init__(self, library_ctx):
77
super().__init__(library_ctx)
88

9-
async def capture_page_screenshot(self, path: str):
9+
async def capture_page_screenshot(self, path: str, fullPage: bool):
1010
return await self.library_ctx.get_current_page().get_page().screenshot(
11-
{'path': path}
11+
{
12+
'path': path,
13+
'fullPage': fullPage
14+
}
1215
)

0 commit comments

Comments
 (0)