ChromeDriver:自定义的Chrome可执行文件路径 [英] ChromeDriver: Custom Chrome Executable Path

查看:809
本文介绍了ChromeDriver:自定义的Chrome可执行文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用便携式谷歌浏览器版本。



因为WebDriver需要默认安​​装路径,所以它找不到明显位于其他位置的便携版本:

 线程main中的异常org.openqa.selenium.WebDriverException:未知错误:找不到Chrome二进制文件
(驱动程序信息:chromedriver = 2.9.248315,platform = Windows NT 6.1 SP1 x86_64)(警告:服务器没有提供任何堆栈跟踪信息)
命令持续时间或超时:11.13秒
构建信息:版本: '2.35.0',修订:'8df0c6b',时间:'2013-08-12 15:43:19'
系统信息:os.name:'Windows 7',os.arch:'amd64', os.version:'6.1',java.version:'1.8.0_05'
驱动程序信息:org.openqa.selenium.chrome.ChromeDriver

如何为 chrome.exe 文件设置自定义路径?

解决方案

没关系,我自己找到了答案:

  ChromeOptions options = new ChromeOptions(); 
options.setBinary(/ path / to / chrome / binary);

ChromeDriver驱动程序=新的C​​hromeDriver(选项);

Chromedriver文档


I'm using the portable version of Google Chrome.

Since WebDriver expects the default installation path, it does not find the portable one which obviously is at another location:

Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary
  (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 11.13 seconds
Build info: version: '2.35.0', revision: '8df0c6b', time: '2013-08-12 15:43:19'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_05'
Driver info: org.openqa.selenium.chrome.ChromeDriver

How do I set a custom path to the chrome.exe file?

解决方案

Nevermind, I found the answer myself:

ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/chrome/binary");

ChromeDriver driver = new ChromeDriver(options);

Chromedriver docs

这篇关于ChromeDriver:自定义的Chrome可执行文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆