How to maximise Screen use in Pupeteer ( non-headless )
You probably would want to set a certain screen size, which any real browser has:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({ width: 1366, height: 768});
await page.goto('https://example.com', {waitUntil: 'networkidle2'});
await page.screenshot({path: 'example.png'});
browser.close();
})();
const puppeteer = require('puppeteer-core');
(async () => {
const browser = await puppeteer.launch({
headless: false,
defaultViewport: null,
});
const pages = await browser.pages();
const page = pages[0];
await page.goto('https://google.com');
})();
Source: https://github.com/GoogleChrome/puppeteer/issues/3688#issuecomment-453218745
you can user options in launch
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
args:[
'--start-maximized' // you can also use '--start-fullscreen'
]
});
const page = await browser.newPage();
await page.setViewport({ width: 1366, height: 768});
await page.goto('https://example.com', {waitUntil: 'networkidle2'});
await page.screenshot({path: 'example.png'});
browser.close();
})();