【发布时间】:2018-09-01 18:15:26
【问题描述】:
我正在开发一个 Electron 应用程序。主进程打开第一个渲染器(browserWindow)。当用户点击一个按钮时,这个渲染器会向主进程发送一条 IPC 消息。收到此消息后,主进程打开第二个不同的渲染器。这两个渲染器同时存在。该应用程序运行良好。
那么,使用 Spectron 测试这个应用程序,如何访问这两个渲染器?问题是app.rendererProcess 总是返回第一个渲染器。
app.client 也存在同样的问题,它始终包含第一个渲染器的 WebdriverIO browser 对象,而不是第二个。
有没有办法在测试中列出 Spectron 应用程序的所有进程?是否可以访问第二个渲染器的browser 对象?
使用 AVA:
test.(async t => {
// the application is open before the test
// at this point, the first renderer is open
// click on the button to open the second renderer
await t.context.app.client.click('#bt_openSecondRenderer');
// wait for the second renderer to open
// error: this element doesn't exist
await t.context.app.client.click('elt_of_the_scnd_renderer');
});
我正在使用 AVA,但我认为这不是问题所在。因此,如果有人知道如何使其与 Mocha 或其他任何东西一起使用,那将非常有帮助。
谢谢!
【问题讨论】:
标签: mocha.js electron webdriver-io ava spectron