Selenium 3 -how to locate the chromedriver and geckodriver place?
Maybe you met these exceptions sometimes:
1. Chrome Driver
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
2. Firefox Driver
The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
After checking the selenium source code, I had found that the rule how they located these drivers in new selenium 3 API:
Invoke the WebDriver
org.openqa.selenium.chrome.ChromeDriver.ChromeDriver() ChromeDriverService.createDefaultService(); new Builder().usingAnyFreePort().build(); org.openqa.selenium.remote.service.DriverService.Builder.build(); org.openqa.selenium.chrome.ChromeDriverService.Builder.findDefaultExecutable() org.openqa.selenium.remote.service.DriverService.findExecutable(String, String, String, String)
String defaultPath = CommandLine.find(exeName);
String exePath = System.getProperty(exeProperty, defaultPath);
checkState(exePath != null,
"The path to the driver executable must be set by the %s system property;"
+ " for more information, see %s. "
+ "The latest version can be downloaded from %s",
exeProperty, exeDocs, exeDownload);
public String find(String named) {
File file = new File(named);
if (canExecute(file)) {
return named;
}
if (Platform.getCurrent().is(Platform.WINDOWS)) {
file = new File(named + ".exe");
if (canExecute(file)) {
return named + ".exe";
}
}
addPathFromEnvironment();
if (Platform.getCurrent().is(Platform.MAC)) {
addMacSpecificPath();
}
for (String pathSegment : pathSegmentBuilder.build()) {
for (String ending : ENDINGS) {
file = new File(pathSegment, named + ending);
if (canExecute(file)) {
return file.getAbsolutePath();
}
}
}
return null;
}
1. First option is place the driver file in your current WebDriver or RemoteWebDriver instance,for example:
If you current selenium server path is: /usr/selenium-server-version.jar ,then you must put the driver into this place
/usr and also MUST NOT change the driver’s name .
2. Add the driver into the PATH environment variable, in linux kernel system, you can put it into this place: /etc/paths.
For windows system you can put it in System environment or User environment Path variable .and also MUST NOT change the driver’s name.
3. Using programmatically java Code: System.setProperty(“”,””) here you can change the driver’s name.
Issues: Selenium Server is developed by Java, and using System.getEnv() to find the PATH variable ,so maybe the cache issue ,cannot located it correctly. When you changed the environment Path for chromedriver you need to restart the Java virtual machine again to make the changes affected.
Selenium 3 -how to locate the chromedriver and geckodriver place?的更多相关文章
- ubuntu下的python请求库的安装——Selenium,ChromeDriver,GeckoDriver,PhantomJS,aiohttp
Selenium安装: pip3 install selenium ChromeDriver安装: 在这链接下载对应版本:https://chromedriver.storage.googleapis ...
- Python selenium web UI之Chrome 与 Chromedriver对应版本映射表及下载地址和配置(windows, Mac OS)
浏览器及驱动下载 进行web UI 自动化时,需要安装浏览器驱动webdriver,Chrome浏览器需要安装chromedriver.exe 驱动,Firefox需安装 geckodriver.ex ...
- jenkins 构建selenium python (浏览器驱动是chromedriver)的解决方法
1.在chrome浏览去中输入chrome://version 查看chrome 的安装位置 2.将chromedriver 驱动添加到可执行文件路径中 3.在Jenkins中 的系统设置中-环境变 ...
- selenium启动chrome出错处理:Message: 'chromedriver' executable needs to be in PATH
- Mac安装chromedriver和geckodriver
DY@MacBook-Pro bin$brew install chromedriver Error: No available formula with the name "chromed ...
- python使用selenium安装chromedriver的问题
环境 win64位,python3.6, 问题与解决 说来也巧,今天无意中解决了两个多月前的问题,即用selenium调用chrome浏览器报错的问题:起因是在知乎中看到了一篇12306抢票的文章,用 ...
- selenium中使用chromedriver备忘
chromedriver是chrome浏览器的webdriver的一个实现.ChromeDriver是由Chrome开发团队来完成的因而ChromeDriver不包含在selenium包中,需要从Ch ...
- selenium使用ChromeDriver
什么是ChromeDriver? ChromeDriver是Chromium team开发维护的,它是实现WebDriver有线协议的一个单独的服务.ChromeDriver通过chrome的自动代理 ...
- use selenium+chromedriver to taobao automatically
原理 利用chromedriver来驱动chrome进行各种模拟各种行为操作, 然后利用selenium提供的接口来操作chromedriver. 安装ChromeDriver 当然这个的默认前提是你 ...
随机推荐
- 获取当前html标签自定义属性的值
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- 【09_242】Valid Anagram
Valid Anagram My Submissions Question Total Accepted: 43694 Total Submissions: 111615 Difficulty: Ea ...
- 4.2.1 网络请求之HTTP
HTTP请求&响应:(常用的只有Post与Get,还有Head/put/delete/connect/options/trace) Get&Post(建议用post规范参数传递方式,并 ...
- 数据库知识整理<二>
又继续写的博客,希望自己能坚持每天写博客.分享自己的点滴,对自己成长有帮助.今天下午高强度打了三个小时篮球,小腿都抽筋了.很爽,失落的心情似乎变得开明了一些.想到了一句话:“像SB式的坚持总会有好的收 ...
- SQL SERVER--单回话下的死锁
很多时候,死锁由两个或多个会话请求其他Session持有的锁而同时又持有其他Session,但也有一些特殊的死锁仅由单个Session锁触发,今天看到一篇相关的文章,搬运过来与各位共享! 引发死锁的代 ...
- 为什么心跳包(HeartBeat)是必须的?
几乎所有的网游服务端都有心跳包(HeartBeat或Ping)的设计,在最近开发手游服务端时,也用到了心跳包.思考思考,心跳包是必须的吗?为什么需要心跳包?TCP没有提供断线检测的方法吗?TCP提供的 ...
- 旋转V字俄罗斯方块
实现效果如图,也就是一个图像的旋转.注意,旋转后的文字是相对应的,而且文字还是立起的.第一次点击时显示,第二次点击时开始旋转.下面是我做这个效果的记录,方法这么差,我也就不说什么了. 先上HTML/C ...
- paip.Java Annotation注解的作用and 使用
paip.Java Annotation注解的作用and 使用 作者Attilax 艾龙, EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http://blog. ...
- Windows Error Code(windows错误代码详解)
0 操作成功完成. 1 功能错误. 2 系统找不到指定的文件. 3 系统找不到指定的路径. 4 系统无法打开文件. 5 拒绝访问. 6 句柄无效. 7 存储控制块被损坏. 8 存储空间不足,无法处理此 ...
- 更新日志 - BugHD 全面开放 API 文档
Hey, 上周 BugHD 全面更新 API 文档,上线一些新的功能,让你可以轻松掌控 Crash ,更方便分享.定位和解决.同时,新版 fir.im 也有所优化,希望你们会喜欢. 具体如下: 开放 ...