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:
parent
acb6e2638b
commit
49075cc732
2 changed files with 6 additions and 1 deletions
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue