Skip to content

Commit af3e4c4

Browse files
committed
wait for rendering to complete
1 parent dc588dd commit af3e4c4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/browser.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export class Browser {
2222
validateOptions(options) {
2323
options.width = parseInt(options.width) || 1000;
2424
options.height = parseInt(options.height) || 500;
25+
options.timeout = parseInt(options.timeout) || 30;
2526

2627
if (options.width > 3000 || options.width < 10) {
2728
options.width = 2500;
@@ -51,6 +52,14 @@ export class Browser {
5152

5253
await page.goto(options.url);
5354

55+
// wait for all panels to render
56+
await page.waitForFunction(() => {
57+
var panelCount = document.querySelectorAll('.panel').length;
58+
return (<any>window).panelsRendered >= panelCount;
59+
}, {
60+
timeout: options.timeout * 1000
61+
});
62+
5463
if (!options.filePath) {
5564
options.filePath = uniqueFilename(os.tmpdir()) + '.png';
5665
}

0 commit comments

Comments
 (0)