ChromeDriver: Custom Chrome Executable Path(ChromeDriver:自定义 Chrome 可执行文件路径)
问题描述
我使用的是便携版的谷歌浏览器.
I'm using the portable version of Google Chrome.
由于 WebDriver 需要默认安装路径,它没有找到明显在另一个位置的便携式:
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
如何设置 chrome.exe
文件的自定义路径?
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 文档
这篇关于ChromeDriver:自定义 Chrome 可执行文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ChromeDriver:自定义 Chrome 可执行文件路径


基础教程推荐
- 大摇大摆的枚举 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- Java Swing计时器未清除 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01