Merge branch 'master' of github.com:johnbintz/persistent_selenium
This commit is contained in:
commit
8552f6a336
19
README.md
19
README.md
@ -19,11 +19,19 @@ require 'persistent_selenium/driver'
|
|||||||
Capybara.default_driver = :persistent_selenium
|
Capybara.default_driver = :persistent_selenium
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you're using Cucumber, you can also install that hook:
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
persistent_selenium install
|
||||||
|
```
|
||||||
|
|
||||||
Should work just the same as if you used the standard Capybara Selenium driver, except for
|
Should work just the same as if you used the standard Capybara Selenium driver, except for
|
||||||
these two differences:
|
these two differences:
|
||||||
|
|
||||||
* The browser starts up first thing and sticks around.
|
* The browser starts up first thing and sticks around, so you don't pay the startup/shutdown
|
||||||
* The last page you were on before your tests passed/failed stays there, so you can inspect it.
|
penalty with each test run.
|
||||||
|
* The last page you were on before your tests passed/failed stays there, so you can inspect it
|
||||||
|
and adjust your tests.
|
||||||
|
|
||||||
The browser's cookies and such are reset before the next test runs, so you still get the state
|
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.
|
cleared out before your next set of tests.
|
||||||
@ -32,3 +40,10 @@ cleared out before your next set of tests.
|
|||||||
|
|
||||||
It's DRb, which Just Works (tm), and a little reshuffling of the default Capybara Selenium driver's code.
|
It's DRb, which Just Works (tm), and a little reshuffling of the default Capybara Selenium driver's code.
|
||||||
|
|
||||||
|
#### When DRb doesn't Just Work (tm)
|
||||||
|
|
||||||
|
You may see recycled object errorrs. Capybara is complex enough that, eventually, something
|
||||||
|
will get garbage collected on the server and an object on the client will notice.
|
||||||
|
I turned off garbage collection on the server but it still happens.
|
||||||
|
Just rerun the test. It doesn't happen too often. It's the price you pay for speed.
|
||||||
|
|
||||||
|
@ -4,4 +4,5 @@ $: << File.expand_path('../../lib', __FILE__)
|
|||||||
|
|
||||||
require 'persistent_selenium/cli'
|
require 'persistent_selenium/cli'
|
||||||
|
|
||||||
|
GC.disable
|
||||||
PersistentSelenium::CLI.start
|
PersistentSelenium::CLI.start
|
||||||
|
@ -6,6 +6,7 @@ module PersistentSelenium
|
|||||||
class Browser < Capybara::Selenium::Driver
|
class Browser < Capybara::Selenium::Driver
|
||||||
def initialize(browser_type)
|
def initialize(browser_type)
|
||||||
@browser_type = browser_type
|
@browser_type = browser_type
|
||||||
|
@__found_elements__ = []
|
||||||
end
|
end
|
||||||
|
|
||||||
def browser
|
def browser
|
||||||
@ -56,10 +57,6 @@ module PersistentSelenium
|
|||||||
# instead.
|
# instead.
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
GC.enable
|
|
||||||
GC.start
|
|
||||||
GC.disable
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def starting_page
|
def starting_page
|
||||||
|
@ -3,6 +3,12 @@ require 'persistent_selenium'
|
|||||||
|
|
||||||
module PersistentSelenium
|
module PersistentSelenium
|
||||||
class CLI < Thor
|
class CLI < Thor
|
||||||
|
include Thor::Actions
|
||||||
|
|
||||||
|
def self.source_root
|
||||||
|
File.expand_path('../../../skel', __FILE__)
|
||||||
|
end
|
||||||
|
|
||||||
desc "start", "Start the server"
|
desc "start", "Start the server"
|
||||||
method_options :port => PersistentSelenium.port, :browser => PersistentSelenium.browser
|
method_options :port => PersistentSelenium.port, :browser => PersistentSelenium.browser
|
||||||
def start
|
def start
|
||||||
@ -16,14 +22,19 @@ module PersistentSelenium
|
|||||||
|
|
||||||
puts "Starting persistent_selenium on #{PersistentSelenium.port} with #{PersistentSelenium.browser}"
|
puts "Starting persistent_selenium on #{PersistentSelenium.port} with #{PersistentSelenium.browser}"
|
||||||
|
|
||||||
browser = Browser.new(PersistentSelenium.browser)
|
@browser = Browser.new(PersistentSelenium.browser)
|
||||||
browser.browser
|
@browser.browser
|
||||||
|
|
||||||
DRb.start_service PersistentSelenium.url, browser
|
DRb.start_service PersistentSelenium.url, @browser
|
||||||
|
|
||||||
DRb.thread.join
|
DRb.thread.join
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "install", "Install Cucumber hook for using persistent selenium"
|
||||||
|
def install
|
||||||
|
directory '.', '.'
|
||||||
|
end
|
||||||
|
|
||||||
default_task :start
|
default_task :start
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
11
skel/features/support/persistent_selenium.rb
Normal file
11
skel/features/support/persistent_selenium.rb
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# get the driver ready for use
|
||||||
|
require 'persistent_selenium/driver'
|
||||||
|
|
||||||
|
# set it for all tests
|
||||||
|
# Capybara.default_driver = Capybara.javascript_driver = :persistent_selenium
|
||||||
|
#
|
||||||
|
# or, set it via the ENV, with it being the default
|
||||||
|
# Before do
|
||||||
|
# Capybara.default_driver = Capybara.javascript_driver = (ENV['DRIVER'] || 'persistent_selenium').to_sym
|
||||||
|
# end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user