java - Selenium IE WebDriver 测试后不会关闭/退出

标签 java internet-explorer selenium selenium-webdriver webdriver

我正在为 IE11 运行 selenium 测试,但测试后它不会关闭 IE,即使我使用了 quit() 或 close()。我的代码如下:

        System.setProperty("webdriver.ie.driver", "C:\\selenium\\drivers\\IEDriverServer.exe");
        DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
        caps.setCapability("ignoreZoomSetting", true);
        caps.setCapability("nativeEvents", false);
        driver = new InternetExplorerDriver(caps);
        //test steps
        driver.quit();

有什么想法吗?谢谢。

最佳答案

  • On IE 7 or higher on Windows Vista or Windows 7, you must set the Protected Mode settings for each zone to be the same value. The value can be on or off, as long as it is the same for every zone. To set the Protected Mode settings, choose "Internet Options..." from the Tools menu, and click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled "Enable Protected Mode".

  • Additionally, "Enhanced Protected Mode" must be disabled for IE 10 and higher. This option is found in the Advanced tab of the Internet Options dialog.

  • The browser zoom level must be set to 100% so that the native mouse events can be set to the correct coordinates.

  • For IE 11 only, you will need to set a registry entry on the target computer so that the driver can maintain a connection to the instance of Internet Explorer it creates. For 32-bit Windows installations, the key you must examine in the registry editor is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE. For 64-bit Windows installations, the key is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE. Please note that the FEATURE_BFCACHE subkey may or may not be present, and should be created if it is not present. Important: Inside this key, create a DWORD value named iexplore.exe with the value of 0

来源:https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration

关于java - Selenium IE WebDriver 测试后不会关闭/退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31858717/

相关文章:

非 transient 类成员的 Java PMD 警告

javascript - js Accordion 不工作 IE9

Javascript 在 Internet Explorer 中执行两次

java - 无法在我们只有 td 标签文本的动态表中获取元素

python - Python 中的 Selenium 启动时禁止安全模式?

java - 验证实例是否在 AWS 中运行的安全方法

java - java中将字符串转换为二维数组

css - Firefox/IE 填充/边距修复

java - 当通过 testng 框架执行时,我的 selenium 测试未从 cmd 或 Jenkins 运行。结果 : Total tests run: 0, 失败 : 0, 跳过:0

java - 如何将 JUnit TemporaryFolder @Rule 与 Spring @Value 属性一起使用?