ChromeDriver cannot find Chrome binary问题解决
来源:互联网 发布:windows 10 安装.net 编辑:程序博客网 时间:2024/05/16 13:52
1、运行程序
@Test
public void testChrome() throws InterruptedException {
System.setProperty("webdriver.chrome.driver","D:\\codeware\\eclipse\\eclipse_neon_workspace\\selenium\\resources\\chromedriver.exe");
WebDriver dr = new ChromeDriver();
dr.manage().window().maximize();
dr.get("http://localhost:8080/jenkins/");
Thread.sleep(2000);
// dr.manage().window().maximize();
dr.findElement(By.id("j_username")).sendKeys("admin");
dr.findElement(By.name("j_password")).sendKeys("352cba3875a2446abd5935b1a60d726f");
dr.findElement(By.id("yui-gen1-button")).click();
}
2、出现的问题
Starting ChromeDriver (v2.4.226107) on port 9496
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.4.226107,platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
3、解决
添加:
ChromeOptions options = new ChromeOptions();
options.setBinary("C:/Program Files (x86)/Google/Chrome/chrome.exe");
WebDriver dr = new ChromeDriver(options);
@Test
public void testChrome() throws InterruptedException {
System.setProperty("webdriver.chrome.driver","D:\\codeware\\eclipse\\eclipse_neon_workspace\\selenium\\resources\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.setBinary("C:/Program Files (x86)/Google/Chrome/chrome.exe");
WebDriver dr = new ChromeDriver(options);
dr.manage().window().maximize();
dr.get("http://localhost:8080/jenkins/");
Thread.sleep(2000);
// dr.manage().window().maximize();
dr.findElement(By.id("j_username")).sendKeys("admin");
dr.findElement(By.name("j_password")).sendKeys("352cba3875a2446abd5935b1a60d726f");
dr.findElement(By.id("yui-gen1-button")).click();
}
之后就能运行了
- ChromeDriver cannot find Chrome binary问题解决
- cannot find Chrome binary问题解决办法
- webdriver + jenkins执行用例报“unknown error: cannot find Chrome binary”
- [webdriver] webdriver : jenkins windows : Message: unknown error: cannot find Chrome binary
- selenium.common.exceptions.webdriverexception: message: unknown error: cannot find Chrome binary
- cannot find lua等问题解决
- chrome及chromedriver
- ChromeDriver 与chrome 版本
- Node.js Cannot find module 'xxx' 问题解决
- QFontDatabase: Cannot find font directory问题解决方案
- /usr/bin/ld: cannot find -lxxx 问题解决
- chromedriver与chrome版本对应
- chrome与chromedriver版本匹配
- chrome XMLHttpRequest cannot load file跨域问题解决
- cannot find the rxvt.exe or sh.exe binary 解决办法
- WebDriverException: Cannot find firefox binary in PATH."的解决方法
- WebDriverException: Cannot find firefox binary in PATH."的解决方法
- cannot find gtk+/x11 2.4(or above version)!问题解决
- Centos7-1611 安装LAMP
- 对MapReduce一些理解
- 1018. 锤子剪刀布 (20)
- leetcode 15. 3Sum
- 利用java 编写简易贪吃蛇游戏
- ChromeDriver cannot find Chrome binary问题解决
- Java Character
- HTML5 Canvas画布
- 第11章 持有对象
- 欢迎使用CSDN-markdown编辑器
- [题解] POJ 3107 Godfather(树型DP 求树的直径)
- Hive优化总结(1)
- VMware中安装 Windows NanoServer
- 深入理解DIP、IoC、DI以及IoC容器