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?的更多相关文章

  1. ubuntu下的python请求库的安装——Selenium,ChromeDriver,GeckoDriver,PhantomJS,aiohttp

    Selenium安装: pip3 install selenium ChromeDriver安装: 在这链接下载对应版本:https://chromedriver.storage.googleapis ...

  2. Python selenium web UI之Chrome 与 Chromedriver对应版本映射表及下载地址和配置(windows, Mac OS)

    浏览器及驱动下载 进行web UI 自动化时,需要安装浏览器驱动webdriver,Chrome浏览器需要安装chromedriver.exe 驱动,Firefox需安装 geckodriver.ex ...

  3. jenkins 构建selenium python (浏览器驱动是chromedriver)的解决方法

    1.在chrome浏览去中输入chrome://version  查看chrome 的安装位置 2.将chromedriver 驱动添加到可执行文件路径中 3.在Jenkins中 的系统设置中-环境变 ...

  4. selenium启动chrome出错处理:Message: 'chromedriver' executable needs to be in PATH

  5. Mac安装chromedriver和geckodriver

    DY@MacBook-Pro bin$brew install chromedriver Error: No available formula with the name "chromed ...

  6. python使用selenium安装chromedriver的问题

    环境 win64位,python3.6, 问题与解决 说来也巧,今天无意中解决了两个多月前的问题,即用selenium调用chrome浏览器报错的问题:起因是在知乎中看到了一篇12306抢票的文章,用 ...

  7. selenium中使用chromedriver备忘

    chromedriver是chrome浏览器的webdriver的一个实现.ChromeDriver是由Chrome开发团队来完成的因而ChromeDriver不包含在selenium包中,需要从Ch ...

  8. selenium使用ChromeDriver

    什么是ChromeDriver? ChromeDriver是Chromium team开发维护的,它是实现WebDriver有线协议的一个单独的服务.ChromeDriver通过chrome的自动代理 ...

  9. use selenium+chromedriver to taobao automatically

    原理 利用chromedriver来驱动chrome进行各种模拟各种行为操作, 然后利用selenium提供的接口来操作chromedriver. 安装ChromeDriver 当然这个的默认前提是你 ...

随机推荐

  1. IOS AFNetworking配置进IOS

    Prefix Header 中填入绝对路径 //PCH 里面加入这个写代码 #ifndef TARGET_OS_IOS #pragma mark ---------- for AFNetwork st ...

  2. SQL删除重复数据

    --首先将不是重复的数据提取出来,保存到一个临时表中 select distinct * into #temp from JX_Score --然后删除原来的表 delete from JX_Scor ...

  3. java对xml文件做增删改查------摘录

    java对xml文件做增删改查 package com.wss; import java.io.File;import java.util.ArrayList;import java.util.Lis ...

  4. hdu 5098 双队列拓扑排序

    http://acm.hdu.edu.cn/showproblem.php?pid=5098 软件在安装之后需要重启才能发挥作用,现在给你一堆软件(有的需要重启有的不需要)以及安装这个软件之前需要哪些 ...

  5. sublime Text3 插件编写教程_第一课

    今天给大家分享一下编写一个Sublime Text3 插件的流程以及使用插件解决的一个实际问题. 一.开发插件的前提条件 开发sublime插件用到的是Python语言,因此必须懂Python语言的基 ...

  6. signalR制作微信墙 开源

    微信墙 上一篇文章中已经用PHP搭建了一个微信墙获取信息的服务器,我这里使用微软的signalr搭建一个客户端,signalr是一个为开发者开发实时应用的 一个库文件,支持windows server ...

  7. HttpClient读取ASP.NET Web API错误信息的简单方法

    在C#中,用HttpClient调用Web API并且通过Content.ReadAsStringAsync()读取响应内容时,如果出现500错误(InternalServerError),会得到一个 ...

  8. TypeScript开发手册

    返回TS学习总目录 基本类型(Basic Types) 接口(Interfaces) 类(Classes) 模块(Modules) 函数(Functions) 泛型(Generics) 常见错误(Co ...

  9. 冲刺阶段day3

    day3 项目进展 今天周三,我们五个人难得的一整个下午都能聚在一起.首先我们对昨天的成果一一地查看了一遍,并且坐出了修改.后面的时间则是做出 登录界面的窗体,完善了登录界面的代码,并且实现了其与数据 ...

  10. ActiveMQ第三弹:在Spring中使用内置的Message Broker

    在上个例子中我们演示了如何使用Spring JMS来向ActiveMQ发送消息和接收消息.但是这个例子需要先从控制台使用ActiveMQ提供的命令行功能启动一个Message Broker,然后才能运 ...