获取错误:
配置失败:@ setUp org.openqa.selenium.WebDriverException:驱动程序可执行文件的路径必须由webdriver.chrome.driver系统属性设置;有关详细信息,请参阅http://code.google.com/p/selenium/wiki/ChromeDriver。最新版本可从http://chromedriver.storage.googleapis.com/index.html下载。
我的代码:
capability = DesiredCapabilities.chrome();
capability.setBrowserName("chrome");
capability.setVersion("38.0.2125.122 m");
String strChromePath = System.getProperty("user.dir")
+ "\\webdrivers\\chromedriver.exe";
System.setProperty("webdriver.chrome.driver", strChromePath);
capability.setPlatform(org.openqa.selenium.Platform.ANY);
return new RemoteWebDriver(new URL("http://192.168.1.77:5555/wd/hub"),
capability);在上面的代码chromedriver上,它没有被调用。
然后我试着用代码:
ChromeDriverService chromeService = new ChromeDriverService.Builder()
.usingDriverExecutable(new File("webdrivers/chromedriver.exe"))
.usingAnyFreePort().build();
chromeService.start();
capability = DesiredCapabilities.chrome();
capability.setBrowserName("chrome");
capability.setVersion("38.0.2125.122 m");
capability.setPlatform(org.openqa.selenium.Platform.ANY);
return new RemoteWebDriver(new URL("http://192.168.1.77:5555/wd/hub"),
capability);在执行上述代码时,将启动可执行文件,但不会调用chrome。它会抛出同样的错误。firefox的代码运行良好。有什么帮助吗?
发布于 2014-11-19 09:39:52
根据您的系统下载相关的Chrome驱动程序(32位/64位),从这里开始。尝试首先设置ChromeDriver的属性,如下所示:
File file = new File("D:\\chromedriver.exe"); //path to the chromedriver.exe so downloaded
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());然后使用以下代码:-
DesiredCapabilities capability = DesiredCapabilities.chrome();
capability.setBrowserName("chrome");
capability.setVersion("38.0.2125.122 m");
WebDriver driver = new RemoteWebDriver(new URL("http://192.168.1.77:5555/wd/hub"),capability);如果不需要使用"RemoteWebDriver",,只需使用下面的代码即可:
File file = new File("D:\\chromedriver.exe"); //path to the chromedriver.exe so downloaded
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
WebDriver driver = new ChromeDriver();发布于 2014-11-19 09:35:52
试着在下面:
WebDriver driver;
System.setProperty("webdriver.chrome.driver", "properties/chromedriver.exe");
driver = new ChromeDriver();
driver.get("www.google.com");将铬驱动程序放在属性文件夹中。
https://stackoverflow.com/questions/27013029
复制相似问题