如何快速下载、安装、配置chromedriver
1、打开chrome浏览器,选择设置->帮助->关于chrome,查看自己浏览器的版本,如图所示
2、对照下图所示的Chrome版本与chromedriver兼容版表,找到适合自己版本的chromedriver
3、打开网站,找到适合自己的版本进行点击 http://npm.taobao.org/mirrors/chromedriver/
4、步骤3后,进入到下图所示的界面,根据自己的需求,选择不同系统的版本进行下载
5、解压步骤4中下载压缩包,找到chromedriver.exe复制到chrome的安装目录
6、可以复制步骤5中chromedriver.exe文件的路径并加入到电脑的环境变量中去,方便以后使用。
参考网址:https://jingyan.baidu.com/album/f7ff0bfcdd89ed2e27bb1379.html?picindex=4
这样就可以不用setProperty来设置驱动程序的路径
7、异常处理:The path to the driver executable must be set by the webdriver.chrome.driver system property;
经实践还是需要setProperty设置谷歌浏览器驱动:System.setProperty("webdriver.chrome.driver","D:\\selenium\\chromedriver.exe")
运行程序报错:
参考网址:https://blog.youkuaiyun.com/qiyueqinglian/article/details/47419209
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 https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
//chromedriver为谷歌浏览器的驱动程序
System.setProperty("webdriver.chrome.driver","D:\\selenium\\chromedriver.exe")
8、运行成功: