selenium启动IE失败,并报错:Unexpected error launching Internet Explorer. Protected Mode settings are not the...

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

 

转载于:https://www.cnblogs.com/haoBo956/p/8760502.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值