Skip to content

Commit

Permalink
Be able to add an additional timeout to wait that the page is fully l…
Browse files Browse the repository at this point in the history
…oaded
  • Loading branch information
sbrunner committed Oct 2, 2023
1 parent a1acf30 commit 4354b60
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions c2cwsgiutils/acceptance/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def check_screenshot(
expected_filename: str,
width: int = 800,
height: int = 600,
sleep: int = 0,
headers: Optional[dict[str, str]] = None,
media: Optional[list[dict[str, str]]] = None,
level: float = 1.0,
Expand Down Expand Up @@ -192,6 +193,7 @@ def check_screenshot(
f"--url={url}",
f"--width={width}",
f"--height={height}",
f"--sleep={sleep}",
f"--headers={json.dumps(headers)}",
f"--media={json.dumps(media)}",
f"--output={actual_filename}",
Expand Down
2 changes: 2 additions & 0 deletions c2cwsgiutils/acceptance/screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ program
.option('--output <char>', 'The output filename')
.option('--width <int>', 'The page width', 800)
.option('--height <int>', 'The page height', 600)
.option('--sleep <int>', 'Sleep that the page is fully loaded [ms]', 0)
.option('--headers <str>', 'The headers', '{}')
// see: https://pptr.dev/api/puppeteer.page.emulatemediafeatures
.option('--media <str>', 'The media feature, see Page.emulateMediaFeatures', '[]');
Expand Down Expand Up @@ -54,6 +55,7 @@ const options = program.opts();
width: parseInt(options.width),
height: parseInt(options.height),
});
await page.waitForTimeout(parseInt(options.sleep));
await page.screenshot({
path: options.output,
clip: { x: 0, y: 0, width: parseInt(options.width), height: parseInt(options.height) },
Expand Down

0 comments on commit 4354b60

Please sign in to comment.