1

我有一组用https://github.com/camme/webdriverjs编写的验收测试。我希望通过 Selenium Server (WebDriver) 和 Sauce Labs 对真实浏览器运行测试。Firefox 启动良好,但 Chromium(来自 Debian Wheezy 软件包的 30.0.1599.101)不能。通过设置{ desiredCapabilities: { browserName: "chrome" } }我得到ERROR COULDNT GET A SESSION ID和 Selenium Server 控制台输出显示

WARN - Exception: 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

如果我启动 Selenium Server 并-Dwebdriver.chrome.driver=/usr/bin/chromium出现新的浏览器窗口,但测试永远不会开始运行,超时后我会得到相同的ERROR COULDNT GET A SESSION ID结果,并且 Selenium Server 控制台输出显示

Created new window in existing browser session. 13:43:25.775 WARN - Exception thrown java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
[...]
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
[...]
Caused by: org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
[...]
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
4

1 回答 1

2

请正确设置 ChromeDriver 的可执行路径。

System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver") //然后你的Driver实例

WebDriver driver = new ChromeDriver();

有关 ChromeDriver 的更多信息,请点击此处

于 2013-11-25T13:16:39.513 回答