Adding Field.xpath_search method with the XPath to all Webrat fields
This commit is contained in:
parent
e0488cd8e4
commit
4736c4cb1a
|
@ -10,6 +10,10 @@ module Webrat
|
||||||
class Field #:nodoc:
|
class Field #:nodoc:
|
||||||
attr_reader :value
|
attr_reader :value
|
||||||
|
|
||||||
|
def self.xpath_search
|
||||||
|
[".//button", ".//input", ".//textarea", ".//select"]
|
||||||
|
end
|
||||||
|
|
||||||
def initialize(form, element)
|
def initialize(form, element)
|
||||||
@form = form
|
@form = form
|
||||||
@element = element
|
@element = element
|
||||||
|
|
|
@ -53,7 +53,7 @@ module Webrat
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_field_with_id(id, *field_types) #:nodoc:
|
def find_field_with_id(id, *field_types) #:nodoc:
|
||||||
field_elements = Webrat::XML.css_search(dom, "button", "input", "textarea", "select")
|
field_elements = Webrat::XML.xpath_search(dom, *Field.xpath_search)
|
||||||
|
|
||||||
field_element = field_elements.detect do |field_element|
|
field_element = field_elements.detect do |field_element|
|
||||||
if id.is_a?(Regexp)
|
if id.is_a?(Regexp)
|
||||||
|
|
Loading…
Reference in New Issue