-
Notifications
You must be signed in to change notification settings - Fork 17
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
Access Electron APIs without IPC bridge #308
Comments
Very interested by this, for one specific reason: I build the app using electron-builder which prune the |
@255kb Yes, this is likely to be a complex piece of work but I think it would be incredibly valuable for the ease of use of the service. The bundling issue is not one I have personally experienced since I routinely bundle my electron apps, but it certainly gives more confidence that finding an alternative to the IPC bridge should be the main feature in development of v7 of the service. |
BiDi is recently supported by WDIO, and has something we might leverage: https://w3c.github.io/webdriver-bidi/#command-script-callFunction |
This is next up, will prototype with CDP first as the service isn't using BiDi yet; can follow up to enable BiDi and look to support BiDi IPC comms when it is enabled, falling back to CDP when it is not. |
Prototyping CDP comms in https://github.com/webdriverio-community/wdio-electron-service/tree/sm/cdp-ipc-bridge-replacement, using An alternative to the fallback approach above is to skip CDP completely, just use BiDi and then give users the option of either using BiDi or sticking with the existing IPC bridge (the latter is perhaps required for older Electron / Chromium versions?) |
You should be able to call |
I tried different combinations of Is there another way to get CDPSession with Puppeteer in WDIO? |
Shouldn't it be: const page = await browser.getPuppeteer()
const cdp = await page.createCDPSession()
await client.send('Animation.enable');
client.on('Animation.animationCreated', () =>
console.log('Animation created!')
);
const response = await client.send('Animation.getPlaybackRate');
console.log('playback rate is ' + response.playbackRate);
await client.send('Animation.setPlaybackRate', {
playbackRate: response.playbackRate / 2,
}); |
Thanks for that, now I have the session I'm now looking at how to get the correct execution context - alternatively, might be able to utilise this flat mode approach. The difference with what we're looking to achieve and that SO post is that the Electron main process isn't accessible from devtools, just the isolated context which I believe is where the preload script is run. A fair bit of trial and error with this stuff. Here is what playwright does, for reference: https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/electron/electron.ts |
@goosewobbler So, I suggest to connect directly node using CDP session. this is implementation of the web socket approach. --> https://github.com/mato533/wdio-electron-service/tree/feature/non-ipc If you are interested in this approach and want the above implementation to work I will give a detailed explanation. |
This was my findings so far as well...
I'm definitely interested in this approach, what are the drawbacks? And what work needs to be done in WebdriverIO? Do you think it would be relatively easy to rework the mocking to use this? I always considered this ticket to be quite a lot of work, but admittedly never got past the "trying to get Electron access through CDPSession" stage. We should get @christian-bromann involved too, and come up with a plan. |
If there is anything we can change in core to make things easier here, let me know. |
@goosewobbler
We believe that there are three things to do:
I don't think it is difficult. I was able to use most of the current implementation in my experimental blanch, and it almost worked with the modifications regarding the CDP session and execute. |
@christian-bromann Please allow me to explain the issues I am aware of and the response that may be necessary on the part of WDIO.
@goosewobbler |
@christian-bromann |
Thanks to @christian-bromann, the fixes on the WDIO side have been merged. Future Tasks on the part of this service should include
|
@mato533 Great breakdown of the work required here, I'll let you drive this one. Feel free to add any sub-tasks to this seeing as Github now supports them. |
Hi @goosewobbler, thanks so much for taking over this task to me! I will create sub-issue if needed and and let's discuss about issue that will happen. By the way, WDIO have been to the release included the changes we had hoped. Then, we did a pretty quick implementation to check the validity of this approach, including whether it really works and whether it worked and met the E2E scenario so far. And we've achieved that! https://github.com/mato533/wdio-electron-service/actions/runs/13193300710 ![]() But there are still unit tests, tentative error handling, inefficient implementations and detailed specifications to consider, so I see this as just a first step! |
I like it, also is it running faster? |
Personally, my feeling is that it's no different, and the CI time hasn't changed significantly either. If anything, the possibility to mock |
Absolutely. I actually just meant the pipeline changes but it makes sense. I don't expect to see a significant reduction in build times until we can build everything in PNPM, remove the hacks and restructure the turborepo build pipeline. |
@goosewobbler It is true that Hack is taking longer, but it appears that the Mac-Universal build (whether forge or builder) is taking just as long. |
Not sure it's a bottleneck as nothing really depends on it but it is definitely one of the larger tasks in the pipeline. It's two mac builds in one so it makes sense. The reason why I'm kind of focussed on the Forge hack as a time saver is that without the hack, we should be able to parallelise more tasks with turborepo...let's see anyway. |
It may be possible to access the Electron APIs via some other mechanism than the IPC bridge in the user-imported main / preload scripts: for instance, Playwright does not appear to use an IPC bridge. Doing this would improve user experience from the first run as a user would no longer need to amend their application code to use the service. We should investigate the use of CDP to execute code in the main process.
https://webdriver.io/docs/devtools-service
https://chromedevtools.github.io/devtools-protocol/tot/Runtime/#method-evaluate
The text was updated successfully, but these errors were encountered: