1
0
Fork 0
mirror of https://github.com/teampoltergeist/poltergeist.git synced 2022-11-09 12:05:00 -05:00
A PhantomJS driver for Capybara
Find a file
2011-10-30 17:38:03 +00:00
ci Test against Capybara 1.0, 1.1 and edge. 2011-10-30 17:37:18 +00:00
lib/capybara Fix intermittent bug where two responses could be sent for one request. 2011-10-30 17:09:43 +00:00
spec Move requires 2011-10-28 19:11:40 +01:00
.gitignore Change this test yet again to not rely on ps, and make it allow up to a second for the executable to be called. 2011-10-28 18:52:06 +01:00
.travis.yml Fix typo in travis config 2011-10-30 17:38:03 +00:00
CHANGELOG.md omg 2011-10-27 23:34:14 +01:00
Gemfile Test against Capybara 1.0, 1.1 and edge. 2011-10-30 17:37:18 +00:00
LICENSE omg 2011-10-27 23:34:14 +01:00
poltergeist.gemspec Test against Capybara 1.0, 1.1 and edge. 2011-10-30 17:37:18 +00:00
Rakefile Define rspec task properly so it does the exit status correctly 2011-10-28 00:36:53 +01:00
README.md omg 2011-10-27 23:34:14 +01:00

Poltergeist - A PhantomJS driver for Capybara

Version: 0.1.0

Poltergeist is a driver for Capybara. It allows you to run your Capybara tests on a headless WebKit browser, provided by PhantomJS.

Installation

Add poltergeist to your Gemfile, and add in your test setup add:

require 'capybara/poltergeist'
Capybara.javascript_driver = :poltergeist

You will also need PhantomJS 1.3+ on your system. Here's how to do that.

Currently PhantomJS is not 'truly headless', so to run it on a continuous integration server you will need to use Xvfb. You can either use the headless gem for this, or make sure that Xvfb is running and the DISPLAY environment variable is set.

What's supported?

Poltergeist supports basically everything that is supported by the stock Selenium driver, including Javascript, drag-and-drop, etc.

Additionally, you can grab screenshots of the page at any point by calling page.driver.render('/path/to/file.png') (this works the same way as the PhantomJS render feature, so you can specify other extensions like .pdf, .gif, etc.)

Customization

You can customize the way that Capybara sets up Poltegeist via the following code in your test setup:

Capybara.register_driver :poltergeist do |app|
  Capybara::Poltergeist::Driver.new(app, options)
end

options is a hash of options. The following options are supported:

  • :phantomjs (String) - A custom path to the phantomjs executable
  • :debug (Boolean) - When true, debug output is logged to STDERR
  • :logger (Object responding to puts) - When present, debug output is written to this object

Bugs

Please file bug reports on Github and include example code to reproduce the problem wherever possible. (Tests are even better.)

Why not use capybara-webkit?

If capybara-webkit works for you, then by all means carry on using it.

However, I have had some trouble with it, and Poltergeist basically started as an experiment to see whether a PhantomJS driver was possible. (It turned out it was, but only thanks to some new features in the recent 1.3.0 release.)

In the long term, I think having a PhantomJS driver makes sense, because that allows PhantomJS to concentrate on being an awesome headless browser, while the capybara driver (Poltergeist) is able to be the minimal amount of glue code necessary to drive the browser.

License

Copyright (c) 2011 Jonathan Leighton

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.