Internet Explorer 11 does not close after Selenium Test

你离开我真会死。 提交于 2019-12-01 17:43:22

问题


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

The capabilities I have set are the following

{
  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"
  }
}

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.


回答1:


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

Thank You, Murali




回答2:


As mentioned by @Sonny in the comments by you might need to kill the "iexplorer.exe" task

I have both in the pre-build events:

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


来源:https://stackoverflow.com/questions/36729512/internet-explorer-11-does-not-close-after-selenium-test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!