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吧!

  • 相关阅读:
    制作centos镜像,启动镜像可以访问本地百度页面
    docker配置镜像加速后报错 系统 CentOS7
    代理方式获取天气预报信息
    周边分析-距离计算
    mysql随笔
    mysql笔记
    树形结构表的存储【转自:http://www.cnblogs.com/huangfox/archive/2012/04/11/2442408.html】
    Mysql中 in 和 exists 区别
    CPU飙高,系统性能问题如何排查?
    位运算的常见操作
  • 原文地址:https://www.cnblogs.com/haoBo956/p/8760502.html
Copyright © 2011-2022 走看看