Sarvavyapi
Sarvavyapi

Reputation: 850

Windows 10 - running a puppeteer script opens a blank Chromium window

I am new to Puppeteer and am trying to run the example script. However, I get a blank chromium window (with no tab or URL bar).

Environment details:
    OS: Windows 10
    Node version: 8.4.0
    NPM version: 6.4.1

I installed puppeteer using NPM and version 1.0.0 got installed. I also installed version 1.9.0 directly from Puppeteer's github page. Both versions have a similar issue.

This is my script:

const puppeteer = require('puppeteer');

(async () => {
    try {
        console.log('starting');
        const browser = await puppeteer.launch({ 
            executablePath: 'D:/Code/Puppeteer/node_modules/puppeteer/.local-chromium/win64-594312/chrome-win/chrome.exe',
            headless: false 
        });
        console.log('one');
        const page = await browser.newPage();
        console.log('two');
        await page.goto('https://github.com');
        console.log('three');
        await page.screenshot({path: 'example.png'});

        console.log("Page is up");
        await browser.close();
    }
    catch (e) {
        console.log("Error: ", e);
    }
})();

In above script, I can see 'starting' and then Chromium window opens with nothing on screen. When I press F12 to bring up the dev tool, I see 'one' being printed on screen.

I have set environment variable 'path' to use this:

D:\Code\Puppeteer\node_modules\puppeteer\.local-chromium\win64-594312\chrome-win; C:\Program Files (x86)\Google\Chrome\Application

Upvotes: 2

Views: 3886

Answers (1)

Sarvavyapi
Sarvavyapi

Reputation: 850

The puppeteer script is working now. I started the node.js cmd window in admin mode to run the script which did not work. Running in normal mode worked.

Upvotes: 2

Related Questions