硒测试后,Internet Explorer 11无法关闭 [英] Internet Explorer 11 does not close after Selenium Test

查看:185
本文介绍了硒测试后,Internet Explorer 11无法关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在运行Selenium测试的Google Cloud上安装了多台Windows Server 2012计算机.他们在NodeJS中与Mocha一起运行. Chrome和Firefox可以按预期启动,运行和关闭,但IE 11不会关闭.结果,硒服务器停止响应,并且IE中的所有测试开始失败.

we have multiple Windows Server 2012 machines setup on Google Cloud where we are running Selenium tests. They are running with Mocha in NodeJS. Chrome and Firefox are starting, running, and closing as expected but IE 11 will not close. As a result, the selenium server stops responding and all the tests in IE begin to fail.

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

Here is the code for my before and after each hooks

// 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并未关闭,因此实际上无法在该浏览器中进行测试.经过约三项测试后,服务器速度变慢,我们必须手动登录并关闭所有窗口.

I've searched around for a few days and have tried different combinations of driver.close(), driver.quit(), IE settings, and capability settings, but they haven't worked and I really don't know what else to try. Since IE is not closing it's making it practically impossible to test in that browser. After about three tests the server slows down and we have to login and close all the windows manually.

推荐答案

如果我们无法通过webdriver命令关闭IE,并且此刻它变得停滞不前,那么为什么我们不能从语言中寻求帮助,也许是Java我要关闭它.

If we are not able to close the IE by webdriver commands and at this moment it becomes stopping stone, so why cant we take help from language may be Java from my side to close it.

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

通过驱动程序命令可以很好地关闭浏览器,但是直到它能正常工作,我希望我们可以在上面尝试一下.参见

Known that good to close browser by driver command but till it get works i hope we can try above. see this

谢谢, 穆拉利

这篇关于硒测试后,Internet Explorer 11无法关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆