selenium 学习笔记 ---新手学习记录(2) 问题总结

本文详细介绍了在使用Firefox、Chrome和IE浏览器执行脚本时可能遇到的问题,并提供了相应的解决方法和配置步骤。对于Firefox,需要设置正确的路径;对于Chrome,需要下载并配置对应的驱动插件;对于IE,需要确保安全区域被正确启用。

今天研究了下ie、chrome、firefox浏览器执行脚本

1.首先firefox下执行时,我是安装在d盘了,所以要更改路径

 //如果火狐浏览器没有默认安装在C盘,需要制定其路径
 System.setProperty("webdriver.firefox.bin", "D:/Softwareinstallation/huohu/firefox.exe");
 WebDriver driver = new FirefoxDriver();

2.在chrome下执行时,遇到了如下问题

Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromedriver/downloads/list

解决方法:

下载chrome驱动插件,(包含ie驱动插件),代码如下,还有问题的话,把路径加到path变量中

http://yunpan.cn/c3kPMJTZDDLyv  访问密码 4dd5

 

1 //谷歌浏览器
2 System.setProperty("webdriver.chrome.driver", "C:\\Users\\Administrator\\Desktop\\testzidong\\selenium\\anzhuangbao\\chromedriver_win32\\chromedriver.exe");       
3 WebDriver driver=new ChromeDriver();
4         

 

3.在ie下运行时出现上面类型问题。解决方法同上

代码如下:

1 System.setProperty("webdriver.ie.driver", "C:\\Users\\Administrator\\Desktop\\testzidong\\selenium\\anzhuangbao\\IEDriverServer_x64_2.48.0\\IEDriverServer.exe"); 
2  WebDriver driver = new InternetExplorerDriver();

但是在运行时又包了其他错。

解决方法如下: 把ie选项中的安全区域全部打上钩

 

转载于:https://www.cnblogs.com/kllay/p/5036932.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值