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
Serenity/Playwright - Support Electron with Playwright #1488
Comments
Hello @hoanvu91! I haven't worked with Electron much, but from the docs you linked, it looks like Playwright for Electron has different APIs than Playwright for Web. It doesn't look like they were fully compatible. In particular, it looks like Playwright Electron has a concept of a "window" rather than a "page" const { _electron: electron } = require('playwright');
(async () => {
// Launch Electron app.
const electronApp = await electron.launch({ args: ['main.js'] });
// Evaluation expression in the Electron context.
const appPath = await electronApp.evaluate(async ({ app }) => {
// This runs in the main Electron process, parameter here is always
// the result of the require('electron') in the main app script.
return app.getAppPath();
});
console.log(appPath);
// Get the first window that the app opens, wait if necessary.
const window = await electronApp.firstWindow(); <- window instead of page
// Print the title.
console.log(await window.title());
// Capture a screenshot.
await window.screenshot({ path: 'intro.png' });
// Direct Electron console to Node terminal.
window.on('console', console.log);
// Click button.
await window.click('text=Click me');
// Exit app.
await electronApp.close();
})(); What you could do, though, is to implement a custom ability to Happy to guide you through it if you'd like, and maybe work on a PR together to bring native support for Playwright/Electron to Serenity/JS? |
Actually, upon closer inspection, Playwright Electron doesn't look that dissimilar from Playwright web. Looks like Playwright Electron also uses So to use Playwright Electron, I think we'd need:
That seems doable; One thing I'm not sure about is how we'd test that integration. Playwright has tests like these and a couple of mini test apps. We could probably reuse some of those ideas. Would you like to take a stab at the PR? |
Hi team,
I'm planning to migrate to using Serenity/Playwright but my application is using Electron, unfortunately BrowseTheWebWithPlaywright only accepts browser so I cannot start Electron with it. Is there a way we can use Electron with BrowseTheWebWithPlaywright as Playwright also supports Electron https://playwright.dev/docs/api/class-electron
The text was updated successfully, but these errors were encountered: