Phantomjs Can';t通过Selenium Grid2使用RemoteWebDriver(Ghost、Phantom)

Phantomjs Can';t通过Selenium Grid2使用RemoteWebDriver(Ghost、Phantom),phantomjs,selenium-grid,ghostdriver,Phantomjs,Selenium Grid,Ghostdriver,我今天试过GhostDriver和Phantomjs。 当我使用GhostDriver时,它工作得很好。 这样开始 phantomjs--webdriver=8910 然后 我的selenium测试用例可以通过 然后我试着用硒酸钠, 因此,我将selenium单机服务器作为一个集线器启动: D:\_Try\selenium>java -jar selenium-server-standalone-2.31.0.jar -role hub 2013-3-20 14:13:49 org.ope

我今天试过GhostDriver和Phantomjs。 当我使用GhostDriver时,它工作得很好。 这样开始

phantomjs--webdriver=8910 然后

我的selenium测试用例可以通过

然后我试着用硒酸钠, 因此,我将selenium单机服务器作为一个集线器启动:

D:\_Try\selenium>java -jar selenium-server-standalone-2.31.0.jar -role hub
2013-3-20 14:13:49 org.openqa.grid.selenium.GridLauncher main
信息: Launching a selenium grid server
2013-03-20 14:13:50.026:INFO:osjs.Server:jetty-7.x.y-SNAPSHOT
2013-03-20 14:13:50.060:INFO:osjsh.ContextHandler:started o.s.j.s.ServletContextHandler{/,null}
2013-03-20 14:13:50.068:INFO:osjs.AbstractConnector:Started SocketConnector@0.0.0.0:4444
然后将GhostDriver注册到中心

C:\Users\administrator>phantomjs  --webdriver=8910 --webdriver-selenium-grid-hub=http://localhost:4444
PhantomJS is launching GhostDriver...
Ghost Driver running on port 8910
Registered with grid hub: http://localhost:4444/ (ok)
然后我通过网格控制台检查了注册:
http://localhost:4444/grid/console
发现phantomjs已经注册。 所以我修改了代码,客户端应该访问网格:

new RemoteWebDriver(new URL("http://localhost:4444"), sCaps);
重新运行selenium测试用例, 我认为它会很好地工作,但异常抛出:

java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:218)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
    at net.pipitest.selenium.trial.ghost.BaseTest.prepareDriver(BaseTest.java:117)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
java.lang.ClassCastException:java.lang.String不能转换为java.util.Map
位于org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:218)
位于org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:111)
位于org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:129)
net.pipitest.selenium.trial.ghost.BaseTest.prepareDriver(BaseTest.java:117)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
位于sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)中
位于java.lang.reflect.Method.invoke(Method.java:597)
我调试了代码, 发现在RemoteWebDriver.class中,响应是Selenium网格页面的源代码(
http://localhost:4444
) 应该是这样的贴图对象(下面是我直接使用GhostDriver时得到的): [platform=windows-7-32位,acceptSslCerts=false,javascriptEnabled=true,browserName=phantomjs,rotatable=false,locationContextEnabled=false,version=phantomjs-1.8.1+ghostdriver-1.0.2,databaseEnabled=false,cssselectorenabled=true,handlesAlerts=false,browserConnectionEnabled=false,webStorageEnabled=false,proxyType=direct},nativeEvents=true,applicationCacheEnabled=false,takesScreenshot=false]

以前有人遇到过这个问题吗? 或者有什么建议? 提前谢谢

  • java-jar selenium-server-standalone-2.31.0.jar-角色中心
    -运行selenium网格中心
  • phantomjs--webdriver=8080--webdriver-selenium-grid-hub=http://localhost:4444
    -在端口8080上运行webdriver并与selenium-grid集成
  • newremotewebdriver(新的URL(“http://{lh或remoteip}:8080”),dCap在dCap中运行PhantomJSDriver必须是phantomjs功能
  • java-jar selenium-server-standalone-2.31.0.jar-角色中心
    -运行selenium网格中心
  • phantomjs--webdriver=8080--webdriver-selenium-grid-hub=http://localhost:4444
    -在端口8080上运行webdriver并与selenium-grid集成
  • newremotewebdriver(新的URL(“http://{lh或remoteip}:8080”),dCap在dCap中运行PhantomJSDriver必须是phantomjs功能

  • 我有一个类似的问题,解决方法很简单
    URL(“http://localhost:4444/wd/hub“”
    而不是
    URL(“http://localhost:4444/“

    我也遇到了类似的问题,解决方法就是简单地使用
    URL(“http://localhost:4444/wd/hub“”
    而不是
    URL(“http://localhost:4444/)

    这个问题运气好吗?这个问题运气好吗?
    java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:218)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
        at net.pipitest.selenium.trial.ghost.BaseTest.prepareDriver(BaseTest.java:117)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)