0

请参阅我的网格批处理文件。(我在路径中添加了 chrome 二进制文件和 chrome 驱动程序位置)

如果我使用 firefox,我的代码可以完美运行,但对于 chrome 和 IE,它会抛出下面给出的异常。我确定我错过了一件非常微不足道的事情,但我无法弄清楚。

Batch file

set HERE=C:\Users\Administrator\Downloads
set JAVA_HOME=%HERE%\jdk-7u13-windows-x64
set PATH=%JAVA_HOME%\jre\bin;%JAVA_HOME%\bin;%CHROME_DRIVER_LOC%;%IE_DRIVER_LOC%;%CHROME_BINARY_LOC%;%PATH%;
set SELENIUM_VERSION=2.29.0
set CHROME_VERSION=chromedriver_win_26.0.1383.0
set HUB_URL=http://localhost:4444/grid/register
set CHROME_DRIVER_LOC=C:\Users\Administrator\Downloads\chromedriver_win_26.0.1383.0\chromedriver.exe
set IE_DRIVER_LOC=C:\Users\Adminstrator\Downloads\IEDriverServer_x64_2.31.0\IEDriverServer.exe
set CHROME_BINARY_LOC=C:\Users\Administrator\AppData\Local\Google\Chrome\Application\chrome.exe
start java -jar selenium-server-standalone-2.29.0.jar -role hub
start java -jar selenium-server-standalone-2.29.0.jar -role node
-Dwebdriver.chrome.driver=%CHROME_DRIVER_LOC% -hub %HUB_URL% -port 5556

My sample code:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
URL url = new URL(“<http://localhost:4444/wd/hub>”);
WebDriver driver = new RemoteWebDriver(url, capabilities);

// And now use this to visit Google
driver.get(“web page”);

Exception I am getting :

Exception in thread “main” org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromedriver/downloads/list
Command duration or timeout: 608 milliseconds
Build info: version: ’2.29.0′, revision: ’58258c3′, time: ’2013-01-17 22:47:00′
System info: os.name: ‘Windows Server 2008 R2′, os.arch: ‘amd64′, os.version: ’6.1′, java.version: ’1.7.0_13′
Driver info: org.openqa.selenium.remote.RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:187)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:533)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:111)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:129)
at test.Test.main(Test.java:32)
Caused by: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see ….

请帮忙!我不明白我做错了什么。很长一段时间以来,我一直在为此苦苦挣扎。任何帮助将不胜感激。

Thanks
Sushmita
4

3 回答 3

1

我认为,下面的行是罪魁祸首

start java -jar selenium-server-standalone-2.29.0.jar -role node
-Dwebdriver.chrome.driver=%CHROME_DRIVER_LOC% -hub %HUB_URL% -port 5556

使用下面的行并检查它是否正常工作。

start java -Dwebdriver.chrome.driver=%CHROME_DRIVER_LOC% -jar selenium-server-standalone-2.29.0.jar -role webdriver -hub %HUB_URL% -port 5556
于 2013-04-09T11:11:55.553 回答
1

一个非常简单的解决方法是将 IEDriverServer 和 chromedriver 可执行文件与 selenium jar 文件放在同一文件夹中

于 2014-06-17T16:10:02.110 回答
1

使用 Chrome 和 IE,您需要定义驱动程序可执行路径,您可以在此处细化文件:http: //code.google.com/p/chromedriver/downloads/listhttp://code.google.com/ p/硒/下载/列表

那么在你创建一个新的 ChromeDriver 之前你需要这样的东西: String chromeDriverPath = "C:\ChromeDriver.exe"; System.setProperty("webdriver.chrome.driver", chromeDriverPath);

于 2013-06-17T06:20:52.640 回答