Playwright: [Feature] Can we have a good example showing how to work with the Electron menu.

Created on 18 Jun 2020  路  2Comments  路  Source: microsoft/playwright

Hi.
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.

P3-collecting-feedback

Most helpful comment

Let me actually bake it into Playwright - it looks useful...

All 2 comments

I don't think Electron allows showing menus programmatically. There are some hints that could be relevant here though: https://github.com/electron-userland/spectron/issues/21#issuecomment-373982282

Let me actually bake it into Playwright - it looks useful...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

etnbrd picture etnbrd  路  4Comments

juliomatcom picture juliomatcom  路  3Comments

arjunattam picture arjunattam  路  4Comments

KevinGrandon picture KevinGrandon  路  4Comments

TrySound picture TrySound  路  4Comments