7

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!

Derrick W
  • 312
  • 3
  • 16
  • I poked around and couldn't see anything obvious for headless. Did you consider running a virtualbox linux for running tests? – Dave McNulla Nov 21 '12 at 22:27

1 Answers1

21

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/

Alister Scott
  • 3,675
  • 24
  • 41
  • 1
    Additionally, it is important to note that you have to install the most recent version of selenium-webdriver. With 2.25.0 people report they could not initialize. Upgrading to selenium-webdriver-2.31.0 allowed driver to work with phantomjs. – flup Mar 20 '13 at 19:07
  • Please help me. I want to turn off the logging information for phantomjs here - http://stackoverflow.com/questions/28117205/how-do-i-turn-off-the-logging-for-phantomjs-in-watir-webdriver – stack1 Apr 05 '15 at 01:15