diff --git a/lib/capybara/dsl.rb b/lib/capybara/dsl.rb index 9054b643..c2af02f2 100644 --- a/lib/capybara/dsl.rb +++ b/lib/capybara/dsl.rb @@ -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 diff --git a/lib/capybara/session.rb b/lib/capybara/session.rb index 85ea4f76..2bac175f 100644 --- a/lib/capybara/session.rb +++ b/lib/capybara/session.rb @@ -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)