Selenium Test后,Internet Explorer 11不会关闭

Son*_*nny 5 selenium mocha.js selenium-webdriver windows-server-2012

我们在Google Cloud上设置了多台Windows Server 2012计算机,我们正在运行Selenium测试.他们在NodeJS中运行Mocha.Chrome和Firefox按预期启动,运行和关闭,但IE 11无法关闭.结果,selenium服务器停止响应并且IE中的所有测试都开始失败.

这是我在每个钩子之前和之后的代码

// Launches browser, opens homepage, and closes the popup.
exports.beforeEach = function(capability) {
   driver = utils.driver.launch(capability);
   utils.driver.open(driver);
   utils.driver.closePopup(driver);
}

exports.afterEach = function() {
  driver.quit();
}
Run Code Online (Sandbox Code Playgroud)

我设置的功能如下

{
  browserName: browser,
  version: version,
  screenResolution: resolution,

  requireWindowFocus: true,
  unexpectedAlertBehaviour: "dismiss",
  ignoreProtectedModeSettings: false,
  ignoreZoomSetting: false,
  nativeEvents: true,
  handlesAlerts: true,
  javascriptEnabled: true,
  enableElementCacheCleanup: true,
  cssSelectorsEnabled: true,
  usePerProcessProxy: false,
  elementScrollBehavior: 0,
  enablePersistentHover: false,
  pageLoadStrategy: "normal",

  ie: {
    ensureCleanSession: true,
    forceCreateProcessApi: true,
    browserCommandLineSwitches: "-private"
  }
}
Run Code Online (Sandbox Code Playgroud)

我已经搜索了几天,并尝试了不同的driver.close(),driver.quit(),IE设置和功能设置组合,但它们没有用,我真的不知道还有什么尝试.由于IE没有关闭,因此几乎无法在该浏览器中进行测试.经过大约三次测试后,服务器速度变慢,我们必须手动登录并关闭所有窗口.

小智 2

如果我们无法通过webdriver命令关闭IE,此时它就成了拦路石,那么为什么我们不能借助我这边可能是Java的语言来关闭它呢?

  try {
Runtime.getRuntime().exec("taskkill /F /IM IEDriverServer.exe");
} catch (IOException e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

知道通过驱动程序命令关闭浏览器很好,但在它正常工作之前我希望我们可以尝试上面的方法。看到这个

谢谢你,穆拉里