-
Notifications
You must be signed in to change notification settings - Fork 16
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 |
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: