在webdriver中启动Chrome浏览器 [英] Start Chrome browser in webdriver
问题描述
抱歉愚蠢的问题,但如何在webdriver中启动Chrome浏览器?
我知道我必须指定chromedriver.exe的路径。问题是我无法下载chromedriver.exe它被删除。我发现的文件也没有.exe扩展名。我正在使用eclipse,Java。请帮忙!
我按照建议一步一步地做了所有事情,但它不起作用。这是我的代码:
Sorry for stupid question, but how to start Chrome browser in webdriver? I know that I have to specify the path to chromedriver.exe. Problem is I unable to download chromedriver.exe it is depricated. Also files that I found doesn't have .exe extension. I am using eclipse, Java. Please help! I did everything step by step as suggested but its doesn't work. Here is my code:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
public class chrome {
@Test public void test(){
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver_win32(2)\\chromedriver");
ChromeDriver driver = new ChromeDriver();
driver.get("http:\\yahoo.com");
}
}
这是错误:
失败:测试
java.lang.IllegalStateException:驱动程序可执行文件不存在:C:\ chromedriver_win32(2)\chromedriver
FAILED: test java.lang.IllegalStateException: The driver executable does not exist: C:\chromedriver_win32(2)\chromedriver
推荐答案
从
http://code.google.com/p/chromedriver/downloads/list
public class ChromeTest {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "E://chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.test.com");
}
}
这篇关于在webdriver中启动Chrome浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!