无法在Selenium Node上进行测试

时间:2012-11-06 21:17:37

标签: java webdriver selenium-grid

我正在使用Selenium Grid进行网页测试。 Selenium Hub:

java -jar selenium-server-standalone-2.25.0.jar -role hub

Selenium Node:

java -jar selenium-server-standalone-2.25.0.jar -role node  -hub http://192.168.55.209:4444/grid/register browser browserName=firefox,platform=WINDOWS

节点已在Hub成功注册。 对于我使用的java代码如下:

@Before
public void setUp() throws Exception,MalformedURLException, IOException {
    DesiredCapabilities browser = DesiredCapabilities.firefox();
    browser.setPlatform(Platform.WINDOWS);
    try{
    driver=new RemoteWebDriver(new URL("http://192.168.55.209:4444/wd/hub"),browser);
                } finally{
                    if (driver != null) {
                                 driver.quit();
                    }
                }

但是当编译器到达时:

driver.get(url);

它给出了如下错误信息,我没有发现问题。

org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 16:53:24'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_07'
Driver info: driver.version: RemoteWebDriver
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:467)
    at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:216)
    at libraries.Globals.login(Globals.java:242)
    at simple.SimplePolicy.simplePolicy(SimplePolicy.java:31)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
    at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:47)
    at org.junit.rules.RunRules.evaluate(RunRules.java:18)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.openqa.selenium.WebDriverException: Session ID may not be null
Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 16:53:24'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_07'
Driver info: driver.version: RemoteWebDriver
    at org.openqa.selenium.remote.HttpCommandExecutor$CommandInfo.get(HttpCommandExecutor.java:560)
    at org.openqa.selenium.remote.HttpCommandExecutor$CommandInfo.getMethod(HttpCommandExecutor.java:544)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:281)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:446)
    ... 30 more

1 个答案:

答案 0 :(得分:0)

在您的配置中,您有browser browserName=firefox,但在-之前忘记了“browser”,因此它应该是:-browser browserName=firefox。这可能是一个问题; webdriver不会给出任何错误,但是特定的“firefox”无法与真正的firefox浏览器相关联。