1

在 Eclipse 中运行 seleniumWebdriver 项目时出现以下错误。

Started ChromeDriver
port=49011
version=26.0.1383.0
log=C:\Users\testuser\workspace\WebDriver_Project\chromedriver.log
Exception in thread "main" 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.
Build info: version: '2.31.0', revision: '1bd294d', time: '2013-02-27 20:53:56'
System info: os.name: 'Windows 8', os.arch: 'amd64', os.version: '6.2', java.version: '1.7.0_17'
Driver info: driver.version: ChromeDriver
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:115)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:161)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:107)
    at test.test.main(test.java:17)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '2.31.0', revision: '1bd294d', time: '2013-02-27 20:53:56'
System info: os.name: 'Windows 8', os.arch: 'amd64', os.version: '6.2', java.version: '1.7.0_17'
Driver info: driver.version: ChromeDriver
    at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:165)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:62)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:527)
    ... 6 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:49011/status] to be available after 20014 ms
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:104)
    at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:163)
    ... 8 more
Caused by: com.google.common.util.concurrent.UncheckedTimeoutException: java.util.concurrent.TimeoutException
    at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:143)
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:79)
    ... 9 more
Caused by: java.util.concurrent.TimeoutException
    at java.util.concurrent.FutureTask$Sync.innerGet(Unknown Source)
    at java.util.concurrent.FutureTask.get(Unknown Source)
    at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130)
    ... 10 more

我在 Eclipse 中的代码如下。我添加了 selenium java zip 文件附带的所有 jar 文件

package test;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class test {

    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\testuser\\Documents\\SW\\Testing\\selenium-2.31.0\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        driver.get("https://www.google.com.au/");
        WebElement element = driver.findElement(By.name("q"));
        element.sendKeys("mysql excel 2013");
        element.submit();
    }

}

请帮助我找出我错在哪里。

4

3 回答 3

0

有人知道吗?如果您在没有 grails 的情况下独立运行它,我的测试工作得很好

于 2014-03-06T17:35:40.037 回答
0

selenium 似乎在等待端口 49011 上的一些响应。可能是其他一些应用程序阻塞了该端口。使用 netstat 检查打开的端口。

于 2013-04-15T11:55:28.423 回答
0

您仍在使用 selenium -2.31.0 \\selenium-2.31.0\\chromedriver.exe。请3.11.0这里安装最新版本的 selenium

也请从这里安装最新版本的 chrome 驱动程序。如果不是最新的任何更高的东西,那么version 2.35应该可以工作。

然后运行你的测试,让我们知道你看到了什么。

于 2018-03-30T15:55:37.890 回答