-
Notifications
You must be signed in to change notification settings - Fork 9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pptr connect with electron failed #3793
Comments
same |
Trying to achieve the same thing and running into the same issue. 😕 Here's a demo snippet const { app, BrowserWindow } = require('electron');
const request = require('axios');
const puppeteer = require('puppeteer-core');
let mainWindow;
app.commandLine.appendSwitch('remote-debugging-port', '9222');
async function createWindow() {
const response = await request.get('http://localhost:9222/json/version');
mainWindow = new BrowserWindow({
width: 1280,
height: 720,
});
mainWindow.on('closed', () => {
mainWindow = null;
});
puppeteer
.connect({
browserWSEndpoint: response.data.webSocketDebuggerUrl,
})
.then(async (browser) => {
const page = await browser.newPage();
await page.goto('https://google.com');
})
.catch((err) => {
console.log(err);
});
} |
same |
@LarenDorr Electron is a custom embedder - and a few DevTools protocol methods are expected to be implemented in an embedder. One of these methods is As a workaround, you can try using Puppeteer v1.4.0. We, however, can make it mostly work with Electron - things like clicking, typing and navigations should be working just fine. Closing this in favor of #4283 - there's some more context. Let's continue discussion there. |
Why this old version might be a workaround ? Because current electron version is based on chromium v68 ? |
This combination seems to work: Refer to: https://github.com/peterdanis/electron-puppeteer-demo, I had to do a small change to make it work, but the idea is there. I was able to generate a png screenshot based on this repo. |
@allavoie I install and run this repo. And found it can success use some methods of puppeteer. After I compare this code. Found just replace args of puppeteer.connect({
browserURL: "http://localhost:9200", // SUCCESS
browserWSEndpoint: "ws://localhost:9200/devtools/browser/xxxxxxx", // FAILURE
}) But some method can't use, such as: |
@LarenDorr : I cannot tell about the completeness of this solution. The only hope I have to go further is to look at this thread: #4283 (comment) |
@LarenDorr Ah, |
@LarenDorr HAHA, just try above methods whether can run. Original because I want to use electron + puppeteer make a crawler application. Electron be used for UI, pptr be used for crawl. But application is so big after bundled(has two chromiums). Now just use puppeteer-core, then connect to electron. |
@LarenDorr If you don't need very fancy UI, you can actually use Puppeteer for the UI as well. We've explored this concept with one of our lab projects - GoogleChromeLabs/carlo. Check it out :-) |
@aslushnikov Yeah, I tried it. Maybe provide two versions application,because someone is sensitive toapplication size. But it's last commit was 2 months ago, will this project continue? |
@aslushnikov Interesting solution, but in real world you don't really want your end-user to install chrome. Electron has the advantage of chromium being bundled. |
environment:
description
Because electron app is a chromium, so I want to use
puppeteer.connect()
connect with electron.I already set electron's chromium with
--remote-debugging-port=9223
.when electron started, I open
http://localhost:9223/json/version
, can get :Then, I use
webSocketDebuggerUrl
set toconnect()
args :when I run this script, log error :
Then I try other different version puppeteer, but also log above error. Include
puppeteer@1.6.x
that support chromium's version equal 69.The text was updated successfully, but these errors were encountered: