PhantomJS 2.0でCasperJSを動かす方法
Sun, Feb 15, 2015現在、PhantomJS2.0の環境でのCasperJSを動かそうとすると、CasperJSが対応していないため次のようなエラーが表示されます。
$ casperjs --version CasperJS needs PhantomJS v1.x /usr/local/Cellar/casperjs/1.1-beta3/libexec/bin/bootstrap.js:91 in __die
解決策を探したところ、原因となっているbootstrap.jsを修正したものをGitHub上にあげてくれている人がいたので、それを適用してみました。
bootstrap.jsのバックアップ
まずは、オリジナルのbootstrap.jsのバックアップを取っておきます。
$ cd /usr/local/Cellar/casperjs/1.1-beta3/libexec/bin/ $ sudo mv bootstrap.js bootstrap.js.org
※/usr/local/Cellar/…パス部分は、casperjsのインストール方法によって異なります。
PhantomJS 2.0用にfixしたbootstrap.jsファイルを取得
CasperJS bootstrap / Phantomjs 2.0 fix
$ sudo wget https://gist.githubusercontent.com/rdpanek/867fc40e68c3160739e1/raw/b785bdf1322b0265a30283fb2f4df460b823f1b2/bootstrap.js $ sudo chmod +x bootstrap.js
動かしてみると、「バグがあっても公式に安定版がリリースされるまで、サポートはされないよ」といった旨の警告が表示されますが、簡単な処理を試したところ、正常に動作している事が確認出来ました。
#バージョンの確認 $ casperjs --version Warning PhantomJS v2.0 not yet released. There will not be any official support for any bugs until stable version is released! 1.1.0-beta3 #http://docs.casperjs.org/en/latest/quickstart.html のsample.jsを使って動作確認 $ casperjs sample.js Warning PhantomJS v2.0 not yet released. There will not be any official support for any bugs until stable version is released! CasperJS, a navigation scripting and testing utility for PhantomJS and SlimerJS PhantomJS | PhantomJS