Selenium远程网络驱动程序无法启动

时间:2015-06-30 15:54:03

标签: java selenium selenium-grid

我为此奋斗了2天。我用谷歌搜索,发现这个问题经常出现在人们面前。我试过他们的解决方案,但他们不适合我。

我有selenium-server-standalone-2.46.0.jar并且我使用这些命令在单独的cmd窗口中启动了hub和node:

java -jar selenium-server-standalone-2.46.0.jar \ -role hub -port 4444

java -jar selenium-server-standalone-2.46.0.jar -role node -hub http://localhost:4444/grid/register -browser browserName=chrome,platform=WINDOWS -remoteHost http://localhost:5555

然后我尝试使用以下代码创建远程Web驱动程序:

public class probna {
    public static void main(String[] args) {
        try {
            System.setProperty(
                    "webdriver.chrome.driver",
                     "D:\\CODE\\proba2\\demos\\src\\main\\java\\com\\nortal\\demos\\chromedriver.exe");
            DesiredCapabilities caps = DesiredCapabilities.chrome();    
            WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), caps);
            driver.get("http://www.google.com");

    } catch (Exception e) {
        e.printStackTrace();
    }

}

}

无论我改变什么,我都会一直得到这个错误:

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:204)

1 个答案:

答案 0 :(得分:0)

如果你运行

,它是否适合你
  

java -jar selenium-server-standalone-2.46.0.jar -role hub -port 4444

而不是:

  

java -jar selenium-server-standalone-2.46.0.jar \ -role hub -port 4444