Allow toggling between css or xpath as the default selecto style.
This commit is contained in:
parent
acb6e2638b
commit
49075cc732
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue