用selenium启动IE时报错

报错信息如下:

Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.ie.driver system property; for more information, see http://code.google.com/p/selenium/wiki/InternetExplorerDriver. The latest version can be downloaded from http://selenium-release.storage.googleapis.com/index.html

经查询相关资料,得知在用selenium启用IE时,还需要一个插件:IEDriverServer.exe。(去这个地址下载就可以:http://vdisk.weibo.com/s/avYXJnY3vlyox)

下载之后将其放在IE的安装目录下:

 

接下来打开IE浏览器,设置->Internet选项->安全,如下图:

需要分别将四个区域的“启用保护模式”的勾取消掉,设置好点击确定。

还需要在项目中增加一段代码:

System.setProperty("webdriver.ie.driver","C:/Program Files/Internet Explorer/IEDriverServer.exe");

完整代码如下:

 

 

 

对了还有,刚才浏览器设置后忘记点确定,然后报了这个错:

Started InternetExplorerDriver server (32-bit)
2.35.3.0
Listening on port 16254
Exception in thread "main" org.openqa.selenium.remote.SessionNotFoundException: 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: 3.32 seconds
Build info: version: '2.45.0', revision: '32a636c', time: '2015-03-05 22:01:35'
System info: host: 'Administrator', ip: '192.168.91.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_80'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver

意思就是浏览器保护模式设置不一致所致,

所以这里也需要注意。

 

转载于:https://www.cnblogs.com/liumeizi/p/9598705.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值