六、ChromeDriver
ChromeDriver是Chromium项目自己支持和维护的,所以必需另外下载安装ChromeDriver,详细的下载地址这里下载。
下载后的chromeDriver.exe文件可放在任意目录。
使用ChromeDriver时要使用webdriver.chrome.driver来指定chromeDriver的位置,具体见实例:
package selenium.test.googleSearch; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class BaiduChromeDriver { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub //设置访问ChromeDriver的路径 System.setProperty("webdriver.chrome.driver", "C:\\Documents and Settings\\Administrator\\Local Settings\\Application Data\\Google\\Chrome\\Application\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("http://www.baidu.com/"); } }
ps:
chrome浏览器安装时默认路径如下:
OSExpectedLocationofChromeLinux/usr/bin/google-chrome1Mac/Applications/Google\Chrome.app/Contents/MacOS/Google\ChromeWindowsXP%HOMEPATH%\LocalSettings\ApplicationData\Google\Chrome\Application\chrome.exeWindowsVistaC:\Users\%USERNAME%\AppData\Local\Google\Chrome\Application\chrome.exe
chrome不能够手动选择安装路径,只能在上述对应的目录下查看chrome文件信息
相关推荐
86417413 2020-11-25
simonzhao0 2020-11-23
zytyxz 2020-10-28
HappyBlog 2020-10-27
爱读书的旅行者 2020-10-26
del 2020-10-21
WenSenli 2020-10-12
ChromeDisaster 2020-10-11
svap 2020-08-25
simonzhao0 2020-08-17
shayuchaor 2020-08-17
yidaizongshi 2020-08-16
化风 2020-08-14
tiankele0 2020-07-29
maowenbei 2020-07-19
curiousL 2020-07-18
王练 2020-07-18
liuweiq 2020-07-08