rearrange and set up readme

This commit is contained in:
John Bintz 2012-11-26 14:10:00 -05:00
parent 31bc976139
commit 2206c1d1d3
4 changed files with 56 additions and 22 deletions

View File

@ -1,29 +1,40 @@
# PersistentSelenium
Now you can keep that precious browser window open when doing continuous integration testing.
Save seconds, and sanity, with every test re-run!
TODO: Write a gem description
Also, the browser stays open at its last state so you can inspect it and fix your tests and/or code.
## Installation
Start an instance:
Add this line to your application's Gemfile:
``` bash
persistent_selenium [ --port 9854 ] [ --browser firefox ]
```
gem 'persistent_selenium'
Tell Capybara to use it:
And then execute:
```
# features/support/env.rb
$ bundle
require 'persistent_selenium/driver'
Capybara.default_driver = :persistent_selenium
```
Or install it yourself as:
Should work just the same as if you used the standard Capybara Selenium driver, except for
these two differences:
$ gem install persistent_selenium
* The browser starts up first thing and sticks around
* The last page you were on before your tests passed/failed stays there, so you can inspect it.
## Usage
The browser's cookies and such are reset before the next test runs, so you still get the state
cleared out before your next set of tests.
TODO: Write usage instructions here
### Under the hood
## Contributing
It's DRb, which Just Works (tm), and a little reshuffling of the default Capybara Selenium driver's code.
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
Copyright © 2012 John Bintz
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.

View File

@ -11,6 +11,10 @@ module PersistentSelenium
@browser ||= Selenium::WebDriver.for(@browser_type)
end
def options
{}
end
def visit(path)
if !path[/^http/]
path = @app_host + path
@ -21,6 +25,20 @@ module PersistentSelenium
def set_app_host(host)
@app_host = host
browser.navigate.to('about:blank')
end
def reset!
if @browser
begin
@browser.manage.delete_all_cookies
rescue Selenium::WebDriver::Error::UnhandledError => e
# delete_all_cookies fails when we've previously gone
# to about:blank, so we rescue this error and do nothing
# instead.
end
end
end
end
end

View File

@ -4,22 +4,27 @@ require 'persistent_selenium'
module PersistentSelenium
class CLI < Thor
desc "start", "Start the server"
method_options :port => PersistentSelenium.port, :browser => PersistentSelenium.browser
def start
require 'persistent_selenium/browser'
require 'drb'
port = ENV['PORT'] || PersistentSelenium.port
browser = ENV['BROWSER'] || PersistentSelenium.browser
PersistentSelenium.configure do |c|
c.port = options[:port]
c.browser = options[:browser]
end
puts "Starting persistent_selenium on #{port} with #{browser}"
puts "Starting persistent_selenium on #{PersistentSelenium.port} with #{PersistentSelenium.browser}"
browser = Browser.new(browser)
browser = Browser.new(PersistentSelenium.browser)
browser.browser
DRb.start_service PersistentSelenium.url, browser
DRb.thread.join
end
default_task :start
end
end

View File

@ -1,6 +1,6 @@
require 'persistent_selenium'
Capybara.register_driver :drb do |app|
Capybara.register_driver :persistent_selenium do |app|
require 'drb'
DRb.start_service