[Feature] Can we have a good example showing how to work with the Electron menu.
See original GitHub issueHi. I’m giving a try to PlayWright to drive my Electron application in my E2E tests. I’m trying hard to find a way to handle the menu of my Electron application to open what should be a configuration popup window. But actually I can’t manage to access and click the menu item to eventually access the configuration dialog window this menu is opening.
I’ve try something like this…
it('should have access to the menu', async () => {
await appElectron.evaluate( async ({Menu}) => {
const menu = Menu.getApplicationMenu();
console.log('menu items count:', menu.items.length);
const configMenu = menu.items[6].click();
configMenu.click();
const userConfigMenu = configMenu.getMenuItemById('User Config');
userConfigMenu.click();
});
const popup = await appElectron.evaluateHandle((async ({BrowserWindow}) => {
return BrowserWindow.getFocusedWindow();
}));
const title = await popup.evaluateHandle((configPopup) => {
return configPopup.getTitle();
});
console.log('Popup title:', title);
expect(title).toBeTruthy();
});
… but this doesn’t work.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
The Complete Electron JS Menu Tutorial (Top Menus, Context ...
Nearly every desktop application you make will need menus. In this detailed tutorial I will show you how to design your menus properly...
Read more >Building desktop applications with Electron - Menu - Medium
There are two kinds of menus in Electron applications, the first one is an application menu and second one is a context menu...
Read more >Chapter 7. Building application and context menus - Electron ...
This chapter covers. Creating menus using Electron's Menu and MenuItem modules; Building menus from a template; Defining custom menus for target operating ...
Read more >Electron - Menus - Tutorialspoint
Electron - Menus, The desktop apps come with two types of menus – the application menu(on the top bar) and a context menu(right-click...
Read more >Menu | Electron
Also on Windows and Linux, you can use a & in the top-level item name to indicate which letter should get a generated...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I was able to click on a sub menu item by doing the following :
The test file:
Let me actually bake it into Playwright - it looks useful…