zoukankan      html  css  js  c++  java
  • selenium启动IE失败,并报错:Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones

    1.selenium去启动IE时,报错:

    Started InternetExplorerDriver server (32-bit)
    2.50.0.0
    Listening on port 24641
    Only local connections are allowed
    Exception in thread "main" org.openqa.selenium.WebDriverException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 1.17 seconds

    2.启动时的代码为:

    package com.chrome.test;

    import org.openqa.selenium.ie.InternetExplorerDriver;

    public class Login_IETest {

    public static void main(String[] args) {
    // 申明driver对象
    System.setProperty("webdriver.ie.driver", "D:\selenium\IEDriverServer.exe");
    InternetExplorerDriver driver = new InternetExplorerDriver();
    // 获取并在浏览器中打开 百度 链接
    driver.get("http://www.baidu.com");

    // 关闭当前焦点所在的窗口
    driver.close();


    }

    }

     解决方法一:

      这个是因为IE浏览器:  工具==》Internet选项==》安全    界面下四个区域设置了 “启用保护模式” ,而我们要做的就是 不启用保护模式

      

      方法一:比较简单直接去IE浏览器设置就OK了

    解决方法二:

    package com.chrome.test;

    import org.openqa.selenium.ie.InternetExplorerDriver;
    import org.openqa.selenium.remote.DesiredCapabilities;

    public class Login_IETest {

    public static void main(String[] args) {
    // 申明driver对象
    System.setProperty("webdriver.ie.driver", "D:\selenium\IEDriverServer.exe");
    // IE的常规设置,便于执行自动化测试
    DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
    ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
    InternetExplorerDriver driver = new InternetExplorerDriver(ieCapabilities);
    // 获取并在浏览器中打开 百度 链接
    driver.get("http://www.baidu.com");
    // 关闭当前焦点所在的窗口
    driver.close();
    }

    }

     方法二:是直接使用加粗的那段代码对IE进行常规设置,方法一和方法二各有其特点,根据自己的需要get吧!

  • 相关阅读:
    PXE无人自动安装系统 大风起
    httpd基于域名的虚拟主机的简单介绍 大风起
    tomcat优化方案 大风起
    tomcat架构 大风起
    Tomcat优化2 大风起
    NET 2.0学习
    删除VS2005历史记录
    在淘宝上建了个小店,在自己的小窝里宣传一下
    微软提供的ASP.NET 2.0空间,你还不赶紧去注册!!呵呵
    DataGridView.BackGroundImage你用过吗?
  • 原文地址:https://www.cnblogs.com/haoBo956/p/8760502.html
Copyright © 2011-2022 走看看