1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

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

View file

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