我正在使用spectron针对我的 Electron 应用程序运行集成测试。除了尝试测试应用程序设置在应用程序重新启动之间是否正确保留之外,一切都工作正常。
运行测试时,我的应用程序会为每个测试启动新的临时 userData
目录,以确保测试是隔离的。这意味着持久性测试理想情况下需要在单个测试中进行,为了实现这一点,我必须在测试过程中重新启动应用程序。有一个 app.restart
方法,所以必须支持这个方法,对吧?
我正在使用以下 Spectron 测试代码:
// save some settings here
await app.restart();
await app.client.waitUntilWindowLoaded()
// do some more checking to ensure the app is fully loaded
// check the settings here
但是我收到以下错误:
Error: waitUntilWindowLoaded Promise was rejected with the following reason:
Error: A session id is required for this command but wasn't found in the response payload
正确的做法是什么?我还尝试停止应用程序实例并启动一个新的应用程序实例,结果类似。
最佳答案
这似乎有效
// save some settings here
await app.stop();
app = new Application({ ... });
await app.start();
await app.client.waitUntilWindowLoaded();
// do some more checking to ensure the app is fully loaded
// check the settings here
关于electron - 使用 Spectron 测试 Electron 应用程序重新启动时丢失 webdriverio session ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42597716/