2

今日はGhostDriverとPhantomjsを試しました。GhostDriver を使用すると、うまく動作します。このように始めます

phantomjs --webdriver=8910 その後

new RemoteWebDriver(new URL("http://localhost:8910"), sCaps);

私のセレンテストケースは合格できます。

次に、Selenium2Grid を使用しようとしたので、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)

次に、Grid コンソールで登録を確認したhttp://localhost:4444/grid/consoleところ、phantomjs が既に登録されていることがわかりました。コードを変更したので、クライアントはグリッドにアクセスする必要があります。

new RemoteWebDriver(new URL("http://localhost:4444"), sCaps);

セレンのテスト ケースを再実行します。うまくいくと思いましたが、例外がスローされます。

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)

コードをデバッグしたところ、RemoteWebDriver.class で、応答が Selenium Grid Page ( http://localhost:4444)のソース コードであることがわかりました。 -7-32bit, acceptSslCerts=false, javascriptEnabled=true, browserName=phantomjs, rotatable=false, locationContextEnabled=false, version=phantomjs-1.8.1+ghostdriver-1.0.2, databaseEnabled=false, cssSelectorsEnabled=true, handlesAlerts=false 、browserConnectionEnabled=false、webStorageEnabled=false、proxy={proxyType=direct}、nativeEvents=true、applicationCacheEnabled=false、takesScreenshot=false]

以前にこの問題に遭遇した人はいますか? または何か提案はありますか?前もって感謝します。

4

2 に答える 2

2
  1. java -jar selenium-server-standalone-2.31.0.jar -role hub- セレン グリッド ハブを実行する
  2. phantomjs --webdriver=8080 --webdriver-selenium-grid-hub=http ://localhost:4444- ポート 8080 で webdriver を実行し、セレン グリッドと統合する
  3. new RemoteWebDriver(new URL("http://{lh or remote ip}:8080"), dCap);dCap で PhanomJSDriver を実行するには、phantomjs 機能が必要です
于 2013-04-04T13:48:55.300 に答える