microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.38k stars 3.63k forks source link

How to launch browser inside electron app? #7044

Closed will-thomson4 closed 3 years ago

will-thomson4 commented 3 years ago

Hello, I am able to launch a chromium browser and manipulate web pages from electron. And at the moment it launches the browser in a new window. However, I was wondering if it would be possible to launch the browser inside the app itself, so that I can can see the browser within the app. Much like how one can use an iframe to load an external page into a web page. Please let me know if I can provide any more info. Thanks.

pavelfeldman commented 3 years ago

When testing Electron, you should launch Electron, not Chromium. See https://playwright.dev/docs/api/class-electronapplication for more details. If you have seen this, please provide a snippet that describes the problem!

will-thomson4 commented 3 years ago

Hi Pavel! Thanks for replying, I'm not trying to use playwright to test Electron, I'm trying to launch playwright from Electron. Which at the moment is quite simple. I just import the file in which I launch Chromium into my Electorn index.js and then run that file when I send something to the IPCMain e.g.

const webScraper = require('./Src/webScraper.js')

ipcMain.on('item:add', function(e, item) {
    webScraper.CollectInfo(item[0], item[1], item[2], item[3])
  });

However this launches a browser in a new window, I want something like this https://www.youtube.com/watch?v=amI6-RJdvE8 where the browser is launched inside of the app. I've reached out to the creator of this video but they haven't got back to me. Do you know how something like this would be possible?

pavelfeldman commented 3 years ago

I see. Unfortunately this use case is outside of the scope of the project, so it is unlikely to be addressed by the core team.