Reputation: 7703
1.How can I run the Puppeteer script on the already installed chrome in mac machine. I tried with the following script, not able to run.
2.Is there any way to open the chrome window with particular window size here I am not talking about viewport, I tried with args "--app-shell-host-window-size=1600x1239" -- not working.
Could anyone help me on the above two issues. Thanks in advance for any help
const puppeteer = require('puppeteer');
(async() => {
const browser = await puppeteer.launch({
headless: false,
executablePath: '/Applications/Google Chrome.app/',
args: ["--app-shell-host-window-size=1600x1239"]
});
const page = await browser.newPage();
await page.goto('http://localhost:8282/publisher/login' ,{
waitUntil: 'load'
});
await page.screenshot({path: '../screenshots/cms-local.png'});
//await browser.close();
})();
After Following the Eric Comment and jegadesh answer below, I changed the code like below and Now it is working except one small issue: window is opening in correct size but content in that window are constrained to some other size, see the screenshot below
Working Code:
const browser = await puppeteer.launch({
headless: false,
// executablePath: '/Applications/Google Chrome.app/',
args: ["--window-size=2400,1239"]
});
Upvotes: 33
Views: 37801
Reputation: 134
Regarding your first question, Puppeteer docs indicate that it could work with an installed version of Chromium or Chrome.
To use an installed version:
Regarding your second question, use --window-size. For example: "--window-size=800,600"
Please be aware that if you have opened a browser window with an explicitly set window-size, then that size will be used for all future windows (ignoring any size you specify for the future windows). For a new window-size to be effective, you must close all previously opened windows.
Upvotes: 1
Reputation: 1248
You can set executablePath: '/Applications/Google Chrome.app/'
...
You can browse chrome://version/
in chrome, and find executableFilePath
(maybe it's not this name, my chrome is not english version), use this.
See Screenshot Below
Upvotes: 110
Reputation: 1889
For me it worked when I set executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
Upvotes: 25