Monday, May 20, 2024
114
rated 0 times [  115] [ 1]  / answers: 1 / hits: 53190  / 6 Years ago, thu, february 8, 2018, 12:00:00

Is it somehow possible to set the browsers (Chrome[ium]) window size like the viewport size?



Setting only the viewport results in a unhandy appearance when the browser is not running headfully and I want to visually see what's going on within the browser instance.



So I would like something like below:



const browser = await puppeteer.launch({
headless: false, // The browser is visible
ignoreHTTPSErrors: true
}),
page = await browser.newPage();


// This is well explained in the API
await page.setViewport({
width: options.width,
height: options.height
});

// But is there something like this (careful this is dummy code)
browser.setWindowSize({
width: options.width,
height: options.height
});


Thanks for any help pointing me into the right direction


More From » google-chrome

 Answers
9

You can set chrome window size during puppeteer.launch with flag --window-size



Here is usage in your example:



const browser = await puppeteer.launch({
headless: false, // The browser is visible
ignoreHTTPSErrors: true,
args: [`--window-size=${options.width},${options.height}`] // new option
});

[#55222] Monday, February 5, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jarod

Total Points: 62
Total Questions: 111
Total Answers: 83

Location: Saint Vincent and the Grenadines
Member since Sat, Sep 11, 2021
3 Years ago
jarod questions
;