Allow toggling between css or xpath as the default selecto style.

This commit is contained in:
Rob Holland 2009-11-25 17:57:32 +00:00
parent acb6e2638b
commit 49075cc732
2 changed files with 6 additions and 1 deletions

View File

@ -1,6 +1,7 @@
module Capybara
class << self
attr_writer :default_driver, :current_driver, :javascript_driver
attr_writer :default_selector
attr_accessor :app
@ -29,6 +30,10 @@ module Capybara
@session_pool = nil
end
def default_selector
@default_selector ||= :xpath
end
private
def session_pool

View File

@ -92,7 +92,7 @@ class Capybara::Session
end
def within(kind, scope=nil)
kind, scope = :xpath, kind unless scope
kind, scope = Capybara.default_selector, kind unless scope
scope = css_to_xpath(scope) if kind == :css
raise Capybara::ElementNotFound, "scope '#{scope}' not found on page" if find(scope).empty?
scopes.push(scope)