Selenium Grid 2 使用 RemoteWebDriver 抛出虚假异常

发布于 2024-12-19 21:11:24 字数 3509 浏览 0 评论 0原文

我有戏了!框架应用程序(基于 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 的行上。我已经尝试了两种设置浏览器的方法,系统输出确认它正确存在。我从来没有看到第二个系统输出。

我做错了什么? :)

I've got a Play! Framework application (based on v1.2.3) using the WebDrive module (based on v0.2) to run the Selenium tests in a browser through WebDriver. I've customised this module to allow me to fire up a RemoteWebDriver to run the tests on another machine.

If I connect this RemoteWebDriver directly to a standalone Selenium server (using v2.14) then everything works fine.

If I set up a Grid configuration with a hub server and a node server that registers with the hub, and then point the RemoteWebDriver at the hub, I get this exception:

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

I am specifying in my capabilities that I want a "firefox" driver, not a "* chrome" one. I've seen that "*browser name" is the older style Selenium RC definition, but I'm not using that anywhere, only the RemoteWebDriver style definition.

Here's the relevant part of the code:

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);

and it falls over on the line where I create the new RemoteWebDriver. I've tried both methods of setting the browser and the sysout confirms that it is in there correctly. I never get to see the second sysout.

What am I doing wrong? :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文