今天研究了下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选项中的安全区域全部打上钩
新闻热点
疑难解答