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 当然这个的默认前提是你 ...
随机推荐
- acm入门编成题
http://wenku.baidu.com/view/c8f2f64acf84b9d528ea7aee.html
- [原]iOS自带社会化分享框架——Social.framework
http://m.blog.csdn.net/blog/u012189584/43236379 Social.framework支持的分享平台(打开手机上的“设置”即可看到)(如Twitter.fac ...
- JSON和js对象之间的相互转化
jQuery插件支持的转换方式 $.parseJSON( jsonstr ); //jQuery.parseJSON(jsonstr),可以将json字符串转换成json对象 http://www. ...
- asp控件Repeater运用
双层repeater嵌套 <asp:Repeater ID="rpt_dataRepeatgroup" runat="server" OnItemData ...
- Jade之Code
Code jade支持内嵌js的代码到jade代码之中. Unbuffered Code 无缓冲代码以-符号开始,无任何额外输出(文本是什么即是什么). jade: - for (var x = 0; ...
- sublim text3 配置
喜欢用sublime,但每次换环境都要重新百度下配置,太麻烦,故在此把自己喜欢的配置记录下来 sublime text2 可以直接在设置里改,但sublime text3不能直接在设置中改值,只能在s ...
- 【实战】初识ListView及提高效率
简介: ListView是手机上最常用的控件之一,几乎所有的程序都会用到,手机屏幕空间有限,当需要显示大量数据的时候,就需要借助ListView来实现,允许用户通过手指上下滑动的方式将屏幕外的数据滚动 ...
- 理解POCO
理解POCO(Plain Old CLR Object)先要理解POJO. 1.什么是POJO? POJO的名称有多种,pure old java object .plain ordinary jav ...
- C++中复制构造函数
复制构造函数 复制构造函数用于: 根据另一个同类型的对象显示或隐式初始化一个对象 复制一个对象,将它作为实参传给一个函数 从函数返回时复制一个对象 初始化顺序容器中的元素 根据元素初始化式列表初始化数 ...
- URAL - 1920 Titan Ruins: the Infinite Power of Magic(乱搞)
搞死人的题目,,, 就是在n*n的方格中找路径长度为L的回路. 开始的思路值适合n为偶数的情况,而忽视了奇数的case,所以wa了一次. 然后找奇数case的策略,代码从70多行变成了100多,然后改 ...