Reputation: 75
I'm trying to run a simple test Puppeteer script where I open Google Chrome and then close it by doing this:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch(
{executablePath: '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'},
{headless: false},
{ignoreHTTPSErrors: true});
const page = await browser.newPage();
await page.goto('https://www.google.com');
await browser.close();
})().catch(error => { console.error("Something bad happend...", error); });;
However, the error I get is:
Something bad happend... ErrorEvent {
target:
WebSocket {
_events:
[Object: null prototype] { open: [Function], error: [Function] },
_eventsCount: 2,
_maxListeners: undefined,
readyState: 3,
protocol: '',
_binaryType: 'nodebuffer',
_closeFrameReceived: false,
_closeFrameSent: false,
_closeMessage: '',
_closeTimer: null,
_closeCode: 1006,
_extensions: {},
_receiver: null,
_sender: null,
_socket: null,
_bufferedAmount: 0,
_isServer: false,
_redirects: 0,
url:
'ws://(my IP address)/devtools/browser/ae12c970-126d-463c-af41-1ab49be03575',
_req: null },
type: 'error',
message: 'connect ECONNREFUSED (my IP address)',
error:
{ Error: connect ECONNREFUSED (my IP address)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '(my IP address)',
port: (my port)} }
Additionally, I've also tried running my code as:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({executablePath: "/mnt/c/'Program Files (x86)'/Google/Chrome/Application/chrome.exe"});
const page = await browser.newPage();
await page.goto('https://www.google.com');
await browser.close();
})();
But I get the error:
(node:2178) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process! spawn /mnt/c/'Program Files (x86)'/Google/Chrome/Application/chrome.exe ENOENT
I'm fairly new to javascript and puppeteer, so I may be missing something obvious. This is part of a larger effort to automate filling in a form online, so it seems that puppeteer is the way to go. However, if anyone has a better suggestion for how to do that, it's much appreciated. Any ideas?
EDIT 1: I downloaded Firefox and linked to that instead of Chrome. When running with the Task Manager open, after a few seconds, a popup would occur. Additionally, Firefox would only be shown as running once that box popped up but not before it. You can see that process in the video linked below:
https://vimeo.com/user119175210/review/436574888/590a38ef10
Upvotes: 3
Views: 3563
Reputation: 653
It happened to me as well. I disabled my antivirus and firewall and then it worked.
Upvotes: 2