8

デフォルトの起動コマンドでセレン グリッド ハブを起動します。

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

そして、同じマシンで Web ドライバー モードで PhantomJS を起動します。

phantomjs --webdriver=8080 --webdriver-selenium-grid-hub=http://127.0.0.1:4444

PhantomJS が起動すると、「All 'OK'」というメッセージしか表示されず、

[INFO  - 2013-09-09T18:10:38.849Z] GhostDriver - Main - running on port 8080
[INFO  - 2013-09-09T18:10:38.850Z] GhostDriver - Main - registering to Selenium HUB 'http://127.0.0.1:4444' using '127.0.0.1:8080'
[INFO  - 2013-09-09T18:11:47.164Z] HUB Register - register - Registered with grid hub: http://127.0.0.1:4444/ (ok)

しかし、そのブラウザを使おうとすると、

driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub',
                          desired_capabilities=DesiredCapabilities.PHANTOMJS)

PhantomJS 実行可能ファイルからの出力を見ると、

[INFO  - 2013-09-09T18:17:12.531Z] Session [0c5c9500-197c-11e3-8eed-b3b7a73965aa] - _decorateNewWindow - page.settings: {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.2 Safari/534.34","webSecurityEnabled":true}
[INFO  - 2013-09-09T18:17:12.531Z] Session [0c5c9500-197c-11e3-8eed-b3b7a73965aa] - page.customHeaders:  - {}
[INFO  - 2013-09-09T18:17:12.531Z] Session [0c5c9500-197c-11e3-8eed-b3b7a73965aa] - CONSTRUCTOR - Desired Capabilities: {"platform":"ANY","javascriptEnabled":true,"browserName":"phantomjs","version":""}
[INFO  - 2013-09-09T18:17:12.531Z] Session [0c5c9500-197c-11e3-8eed-b3b7a73965aa] - CONSTRUCTOR - Negotiated Capabilities: {"browserName":"phantomjs","version":"1.9.2","driverName":"ghostdriver","driverVersion":"1.0.4","platform":"mac-10.7 (Lion)-32bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
[INFO  - 2013-09-09T18:17:12.531Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: 0c5c9500-197c-11e3-8eed-b3b7a73965aa

すべてがうまくいっているように見えますが、コードがクラッシュします:/ 私は巨大なエラースタックトレースを取得します。

selenium.common.exceptions.WebDriverException: Message: u'Error forwarding the new session new session request for webdriver should contain a location header with the session.'

そしてグリッドハブの出力を確認すると、

INFO: Trying to create a new session on test slot {seleniumProtocol=WebDriver, browserName=phantomjs, maxInstances=1}
INFO: Available nodes: [host :http://127.0.0.1:8080 time out : 300000]

また、問題があるようです。何らかの理由で、グリッド ハブは、物事を正しく処理しているように見えても、PhantomJS 実行可能ファイルから情報を取得していないようです。

テストのために、同じマシンでコマンドを使用して通常のセレンノードを実行しています

java -jar selenium-server-standalone-2.33.0.jar -role node

そして、Firefox RemoteWebDriver セッション (Python で) を起動すると、

driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub',
                          desired_capabilities=DesiredCapabilities.FIREFOX)

すべて良好。

すべてが正しく設定されているように見えます。私は物事を「バニラ」として、ドキュメントが言うことにできるだけ近づけていますが、ここでフェンスを乗り越えることはできません.

Javaでも試すとまったく同じエラーが発生します

WebDriver driver = new RemoteWebDriver(DesiredCapabilities.phantomjs());

両方が接続されたグリッド コンソールのスクリーンショット。PhantomJS は健在です。

ここに画像の説明を入力

左はデフォルトの Selenium ノード、右は PhantomJS です (10.0.0.222 は作業中のラップトップの IP アドレスです)。

私のバージョンは、PhantomJS では 1.9.2、セレンでは明らかに 2.33.0 です。

4

1 に答える 1