Processing CSS searches as XPath
This commit is contained in:
parent
56dc8147f2
commit
7ef8fdf7ba
@ -25,9 +25,16 @@ module Webrat #:nodoc:
|
||||
end
|
||||
end
|
||||
|
||||
def self.xpath_search(element, *searches)
|
||||
searches.flatten.map do |search|
|
||||
element.xpath(search)
|
||||
end.flatten.compact
|
||||
end
|
||||
|
||||
def self.css_search(element, *searches) #:nodoc:
|
||||
if Webrat.configuration.parse_with_nokogiri?
|
||||
element.css(*searches)
|
||||
xpath_search(element, css_to_xpath(*searches))
|
||||
# element.css(*searches)
|
||||
else
|
||||
searches.map do |search|
|
||||
element.search(search)
|
||||
@ -35,5 +42,11 @@ module Webrat #:nodoc:
|
||||
end
|
||||
end
|
||||
|
||||
def self.css_to_xpath(*selectors)
|
||||
selectors.map do |rule|
|
||||
Nokogiri::CSS.xpath_for(rule, :prefix => ".//")
|
||||
end.flatten.uniq
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user