selenium - Selenium 测试后 Internet Explorer 11 未关闭

标签 selenium selenium-webdriver mocha.js windows-server-2012

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

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

// 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();
}

我设置的功能如下
{
  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"
  }
}

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

最佳答案

正如@Sonny 在评论中提到的,您可能需要终止“iexplorer.exe”任务

我在预构建事件中都有:

    taskkill /f /fi "pid gt 0" /im IEDriverServer.exe
    taskkill /f /fi "pid gt 0" /im iexplore.exe

关于selenium - Selenium 测试后 Internet Explorer 11 未关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36729512/

相关文章:

python - chromedriver.quit 和 chromedriver.close 不起作用

python - ExpectedCondition.invisibility_of_element_located 需要更多时间(selenium web driver-python)

typescript - Describe is not defined exception on Typescript, Mocha 和 VSCode

javascript - Mocha 模拟导入变量

java - Selenium - 将文本发送到格式化输入

unit-testing - 如何在 Typescript 中对私有(private)方法进行单元测试

python - WebDriver异常: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium on debian server

java - Selenium、Chrome 的 WebDriver 停止窗口打开

perl:不显眼地写入由 TAP::Formatter::HTML 打开的 IO::Handle

Python、Selenium Webdriver : How can I find the value of this attribute?