baronyan's blog

linux,macでruby、railsでの開発をしていく中で知ったこと、備忘的なことなどを書いていきます。

ubuntu12.04(64bit)でpoltergeistを使う方法

前提条件:capybaraが使える状態(参考

 

まずphantomjsをインストールします。(参考ページ

cd /usr/local/share

sudo wget https://phantomjs.googlecode.com/files/phantomjs-1.9.0-linux-x86_64.tar.bz2

sudo tar xjf phantomjs-1.9.0-linux-x86_64.tar.bz2
sudo ln -s /usr/local/share/phantomjs-1.9.0-linux-x86_64/bin/phantomjs /usr/local/share/phantomjs

sudo ln -s /usr/local/share/phantomjs-1.9.0-linux-x86_64/bin/phantomjs  /usr/local/bin/phantomjs

sudo ln -s /usr/local/share/phantomjs-1.9.0-linux-x86_64/bin/phantomjs  /usr/bin/phantomjs


phantomjs --version

でバージョンが表示されたらインストール完了です。

 

 

Gemfileに追記します。

gem 'poltergeist'

 

rubyコード例です。

require 'capybara/poltergeist'

 

その他はcapybaraで使うブラウザがwebkitseleniumの場合と同様です。