watir-webdriver phantomjs and ghostdriver

Derrick W picture Derrick W · Nov 21, 2012 · Viewed 7.3k times · Source

I currently have a rails app that uses rspec and watir-webdriver for my integration tests. I want to run my integration tests in a headless browser (for speed purposes). Since my development is done on a mac the headless gem won't work for me. I am looking to phantomjs as the solution. Whereas phantomjs works well with rspec/capybara (via poltergeist) and there are plenty of examples on how to make that work, I can't find much in the way of getting it to work well with watir-webdriver and ghostdriver.

I have built the "special" phantomjs that ghostdriver requires but I am lost after that. Has anyone used this setup before (rails/watir-webdriver/ghostdriver)?

My main goal is to speed up my integration tests. So if anyone has a better suggestion than what I have described here, I am flexible :)

Any help is greatly appreciated!

Answer

Alister Scott picture Alister Scott · Feb 5, 2013

It is now fully supported by Watir-WebDriver and easy to get running:

Steps to get working on OSX

  • First make sure you have homebrew installed
  • brew update
  • brew install phantomjs
  • Run irb and start using GhostDriver!
require 'watir-webdriver'
b = Watir::Browser.new :phantomjs
b.goto "www.google.com"
b.url #"http://www.google.com.au/"
b.title #"Google"

See full details on this blog post: http://watirmelon.com/2013/02/05/watir-webdriver-with-ghostdriver-on-osx-headless-browser-testing/