我有一个游戏!框架应用程序(基于v1.2.3)使用WebDrive模块(基于v0.2)通过WebDriver在浏览器中运行Selenium测试。我已经定制了这个模块,允许我启动一个RemoteWebDriver来在另一台机器上运行测试。
如果我将此RemoteWebDriver直接连接到独立的Selenium服务器(使用v2.14),那么一切正常。
如果我使用集线器服务器和向集线器注册的节点服务器设置网格配置,然后将RemoteWebDriver指向集线器,则会出现以下异常:
Exception in thread "main" org.openqa.selenium.WebDriverException: Could not start Selenium session: org%2Eopenqa%2Egrid%2Ecommon%2Eexception%2EGridException%3A+Error+forwarding+the+new+session+cannot+find+%3A+%7BbrowserName%3D%2Achrome%7D; duration or timeout: 59 milliseconds
Build info: version: '2.14.0', revision: 'unknown', time: '2011-11-29 13:13:16'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-34-generic', java.version: '1.6.0_26'
Driver info: driver.version: RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:400)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:115)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:76)
at play.modules.webdrive.WebDriverRunner.runRemote(WebDriverRunner.java:204)
at play.modules.webdrive.WebDriverRunner.runDecider(WebDriverRunner.java:64)
at play.modules.webdrive.WebDriverRunner.main(WebDriverRunner.java:56)
Caused by: java.lang.RuntimeException: Could not start Selenium session: org%2Eopenqa%2Egrid%2Ecommon%2Eexception%2EGridException%3A+Error+forwarding+the+new+session+cannot+find+%3A+%7BbrowserName%3D%2Achrome%7D
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:123)
at org.openqa.selenium.internal.selenesedriver.NewSession.apply(NewSession.java:34)
at org.openqa.selenium.internal.selenesedriver.NewSession.apply(NewSession.java:30)
at org.openqa.selenium.SeleneseCommandExecutor.execute(SeleneseCommandExecutor.java:132)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:382)
... 5 more
我在我的能力中指定我想要一个“firefox”驱动程序,而不是“* chrome”驱动程序。我已经看到“* 浏览器名称”是旧式的Selenium RC定义,但我没有在任何地方使用它,只有RemoteWebDriver样式定义。
以下是代码的相关部分:
DesiredCapabilities capabilities = new DesiredCapabilities();
// capabilities.setBrowserName("firefox");
capabilities = DesiredCapabilities.firefox();
System.out.println("<><><><><><><><><><><><><><><><><><><><><><><><>" + capabilities.getBrowserName());
CommandExecutor executor = new SeleneseCommandExecutor(new URL(System.getProperty("webdrive.remoteUrl")), new URL(appUrlBase + "/@tests/init"), capabilities);
WebDriver webDriver = new RemoteWebDriver(executor, capabilities);
System.out.println("~ Starting tests remotely with " + capabilities.getBrowserName());
runTests(seleniumTests, webDriver);
它落在我创建新RemoteWebDriver的行上。我已经尝试了两种设置浏览器的方法,并且sysout确认它在那里正确。我永远不会看到第二个系统。
我做错了什么? :)