Spectron无法正确关闭电子应用程序

时间:2020-07-20 11:51:57

标签: electron spectron

我的140多个测试用例有问题。电子应用程序无法正确关闭。我在一个实用程序类中,可以通过以下方法关闭该电子应用程序,然后登录该应用程序。

public async closeApp(){
if (await this.app.isRunning()) {
  await this.app.client.windowByIndex(1);
  await this.app.client.close()
    .then(() => {
      console.log(`Client fuer ${this.user} was closed`);
    })
    .catch(async(error) => {
    // hard kill the process
    shell.exec(`taskkill /IM "App.exe" /F`, {silent: false, async: false});
    console.log(error);
  });
}
}

我添加了带有taskkill的行,以在发生错误时终止应用程序。应用程序关闭但没有此行,但始终返回

{ Error: A session is either terminated or not started
at windowHandles() - C:\mdk\e2e\node_modules\spectron\node_modules\webdriverio\build\lib\commands\getTabIds.js:33:28
at getTabIds() -

我不知道出了什么问题。

0 个答案:

没有答案