You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently experimenting with adding Electron support to Theia-Playwright. Things seem to progress nicely, however, there are a few issues, one of which I'd be very happy to get your feedback on:
With Playwright, we currently only get access to the Electron application menu:
constapplicationMenu=awaitapp.electronApp.evaluate(async({ Menu })=>{constmenu=Menu.getApplicationMenu();//...returnmenu;});
Querying the menu is crucial for automating tests that involve some interaction with the main menu.
However, in Windows and Linux, Theia configures window-specific menus (see code) and not application-wide menus, which makes sense to fix certain issues when multiple instances (windows) of Theia are opened.
protectedsetMenu(app: FrontendApplication,electronMenu: electron.Menu|null=this.factory.createElectronMenuBar(),electronWindow: electron.BrowserWindow=electronRemote.getCurrentWindow()): void{if(isOSX){electronRemote.Menu.setApplicationMenu(electronMenu);}else{this.hideTopPanel(app);if(this.titleBarStyle==='custom'&&!this.menuBar){this.createCustomTitleBar(app,electronWindow);}// Unix/Windows: Set the per-window menuselectronWindow.setMenu(electronMenu);// <== set window-specific but not the application menu}}
I've raised a question with the Playwright folks, whether there is some way to obtain window menus too. But from what I see in the API, it doesn't seem to be possible.
Thus, it is currently not possible to access the main menu from a Playwright test with Theia.
There are a few somewhat ugly workarounds to be applied in Theia:
Set the application menu and install a window listener to reset it on focus change (similar to how it is done for OSX)
Introduce a mode (enabled by an env variable or theia CLI parameter) to force setting the application menu instead, accepting that the menu will react weirdly when multiple instances of Theia are opened (which probably won't matter in the Playwright testing scenario)
Writing the menu in some other global place in memory that we then access from the Playwright code
All of these solutions are not elegant to say the least. :) So I'm wondering whether you'd have an opinion on those suggestions or even other ideas?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm currently experimenting with adding Electron support to Theia-Playwright. Things seem to progress nicely, however, there are a few issues, one of which I'd be very happy to get your feedback on:
With Playwright, we currently only get access to the Electron application menu:
Querying the menu is crucial for automating tests that involve some interaction with the main menu.
However, in Windows and Linux, Theia configures window-specific menus (see code) and not application-wide menus, which makes sense to fix certain issues when multiple instances (windows) of Theia are opened.
I've raised a question with the Playwright folks, whether there is some way to obtain window menus too. But from what I see in the API, it doesn't seem to be possible.
Thus, it is currently not possible to access the main menu from a Playwright test with Theia.
There are a few somewhat ugly workarounds to be applied in Theia:
All of these solutions are not elegant to say the least. :) So I'm wondering whether you'd have an opinion on those suggestions or even other ideas?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions