PhantomJS のGhostDriverでSeleniumサーバーを実行child_process
するためにモジュールを使用したい Node スクリプトがあります。
モジュールが必要です:
Child = require "child_process"
そして、サーバーを起動してGDを接続しようとしている方法は次のとおりです(Coffeescriptで):
@Selenium = new Child.exec "java -jar selenium/selenium-server-standalone-2.44.0.jar -role hub -port 4444", (error, stdout, stderr) =>
console.log stdout
console.log error if error
@PhantomJS = new Child.exec "phantomjs --webdriver=8080 --webdriver-selenium-grid-hub=http://127.0.0.1:4444", (error, stdout, stderr) =>
console.log stdout
console.log error if error
これは次のとおりですstdout
。@PhantomJS
PhantomJS is launching GhostDriver...
[ERROR - 2014-12-10T18:51:27.587Z] GhostDriver - main.fail - {"message":"Could not start Ghost Driver","line":82,"sourceId":4469911104,"sourceURL":":/ghostdriver/main.js","stack":"Error: Could not start Ghost Driver\n at :/ghostdriver/main.js:82","stackArray":[{"sourceURL":":/ghostdriver/main.js","line":82}]}
さらに、そのコマンドから次のエラーが発生します。{"killed": false, "code": 1, "signal": null}
いくつかのメモ:
- 実際、Selenium jar ファイルは selenium/selenium-server-standalone-2.44.0.jar にあります。
npm update
それが違いを生むかどうかを確認するためだけに試してみました- ポート 4444 で別の何かが実行されているのではないかと思いまし
"PORT_NUMBER=4444 | lsof -i tcp:${PORT_NUMBER} | awk 'NR!=1 {print $2}' | xargs kill"
た。 - この提案に従ってソースからPhantomJSを同じエラーにインストールしようとしました
- これらのコマンドをスクリプトの外で個別に実行すると、すべて正常に動作します