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

  • 相关阅读:
    [公告]Google个性化主页可以正常阅读博客园的RSS了
    致歉
    [公告]网站程序已经升级到ASP.NET 2.0
    GTF: Great Teacher Friedman
    Node.js : exports と module.exports の違い
    拨开历史的迷雾从篡夺者战争到五王之战的政经原因
    javascript模板系统 ejs v10
    window.name + postMessage实现不用代理页的跨域通信
    node.js Domain 時代のエラー処理のコーディングパターン
    鲜为人知的get,set操作符
  • 原文地址:https://www.cnblogs.com/haoBo956/p/8760502.html
Copyright © 2011-2022 走看看