Last active
April 12, 2022 09:19
-
-
Save nitayneeman/69876fea604aed196ad6cdf4c3e25f97 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const chromeLauncher = require('chrome-launcher'); | |
const axios = require('axios'); | |
const puppeteer = require('puppeteer'); | |
(async () => { | |
// Initializing a Chrome instance manually | |
const chrome = await chromeLauncher.launch({ | |
chromeFlags: ['--headless'] | |
}); | |
const response = await axios.get(`http://localhost:${chrome.port}/json/version`); | |
const { webSocketDebuggerUrl } = response.data; | |
// Connecting the instance using `browserWSEndpoint` | |
const browser = await puppeteer.connect({ browserWSEndpoint: webSocketDebuggerUrl }); | |
console.info(browser); | |
await browser.close(); | |
await chrome.kill(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment