Playwright: Electron support

Created on 23 Jan 2020  路  10Comments  路  Source: microsoft/playwright

Hey, very cool that it supports WebKit and Firefox. Do you have plans to support Electron?

Most helpful comment

@aslushnikov
Hi,

Do you have example to launch from index.js and control the electron using playwright?

All 10 comments

I'm assuming you can do it today the same way you would with puppeteer, by enabling the Chrome debugging protocol.

const { app, BrowserWindow } = require('electron')
const puppeteer = require('puppeteer-core')

app.commandLine.appendSwitch('remote-debugging-port', '8315')
const electronBrowser = await puppeteer.connect({
    browserURL: 'http://localhost:8315',
  })

By just converting the correct puppeteer calls to playwright, I haven't tried it for myself though.

Yes, it should be doable by manually hooking up the debugging protocol as corevo says. But I鈥檇 really like to have a nicer solution that just works out of the box.

There are some logistics to work out. Playwright needs to be compatible with the version of electron. Also the way we handle contexts might clash with how electron is implemented. But these both seem like problems that can be overcome.

puppeteer has some issues to support Electron: https://github.com/puppeteer/puppeteer/issues/4283 I was wondering whether it will be the same here.

@akosyakov: in case you are still interested...

https://www.npmjs.com/package/playwright-electron is now publicly available. It does not have docs, just a bare README.md, but it should be enough to get a rough idea about it. Please let us know what you think!

@pavelfeldman cool! thanks. Do I understand correctly that it works only against Electron 9?

Yes, Electron 9+ at this point.

An electron support is now available with playwright-electron! 馃帀

@aslushnikov
Hi,

Do you have example to launch from index.js and control the electron using playwright?

Yes, it should be doable by manually hooking up the debugging protocol as corevo says. But I鈥檇 really like to have a nicer solution that just works out of the box.

My app is built with electron but it needs to load a certain page in the headless browser and read cookies. I don't want to run another headless browser because electron already has the debugger window. How exactly to "hook up" the debugging protocol?

Was this page helpful?
0 / 5 - 0 ratings