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

  • 相关阅读:
    【转载】如何学JavaScript?前辈的经验之谈
    javascript基础学习心得01
    CSS之浮动
    HTML5基础学习心得
    如何使用HTML5的canvas属性
    HTML标记语言
    HTML+CSS学习
    线性表
    (2)协程之 greenlet模块
    (1)协程之理论
  • 原文地址:https://www.cnblogs.com/haoBo956/p/8760502.html
Copyright © 2011-2022 走看看