Converting some CSS selectors to XPath

This commit is contained in:
Bryan Helmkamp 2008-12-02 00:16:15 -05:00
parent e88772021b
commit a205b6fa44
3 changed files with 4 additions and 8 deletions

View File

@ -138,7 +138,7 @@ module Webrat
end
unless id.blank?
@label_elements += Webrat::XML.css_search(form.element, "label[@for='#{id}']")
@label_elements += Webrat::XML.xpath_search(form.element, ".//label[@for = '#{id}']")
end
@label_elements
@ -373,8 +373,8 @@ module Webrat
protected
def default_value
selected_options = Webrat::XML.css_search(@element, "option[@selected='selected']")
selected_options = Webrat::XML.css_search(@element, "option:first") if selected_options.empty?
selected_options = Webrat::XML.xpath_search(@element, ".//option[@selected = 'selected']")
selected_options = Webrat::XML.xpath_search(@element, ".//option[position() = 1]") if selected_options.empty?
selected_options.map do |option|
return "" if option.nil?

View File

@ -9,10 +9,6 @@ module Webrat
".//a[@href]"
end
def self.css_search
"a[@href]"
end
def click(options = {})
method = options[:method] || http_method
return if href =~ /^#/ && method == :get

View File

@ -41,7 +41,7 @@ module Webrat
end
def link_elements
Webrat::XML.css_search(@dom, *Link.css_search)
Webrat::XML.xpath_search(@dom, *Link.xpath_search)
end
def replace_nbsp(str)