Skip to content

Instantly share code, notes, and snippets.

@garywu
Created January 18, 2018 15:58
Show Gist options
  • Save garywu/bcb9259da58c1e70044355b77c9e1078 to your computer and use it in GitHub Desktop.
Save garywu/bcb9259da58c1e70044355b77c9e1078 to your computer and use it in GitHub Desktop.
puppeteer resize browser
I'm using this code:
await page.setViewport({height, width});
// Window frame - probably OS and WM dependent.
height += 85;
https://github.com/GoogleChrome/puppeteer/issues/1183
// Any tab.
const {targetInfos: [{targetId}]} = await browser._connection.send(
'Target.getTargets'
);
// Tab window.
const {windowId} = await browser._connection.send(
'Browser.getWindowForTarget',
{targetId}
);
// Resize.
await browser._connection.send('Browser.setWindowBounds', {
bounds: {height, width},
windowId
});
I think that Tab window + Resize parts could be part browser API such as:
browser.resize({height, width})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment