Updating field_with_id to search DOM elements
This commit is contained in:
parent
3dce02483b
commit
ca0642e35c
@ -189,7 +189,7 @@ module Webrat
|
||||
if collection_name?
|
||||
super
|
||||
else
|
||||
checkbox_with_same_name = @form.field(name, CheckboxField)
|
||||
checkbox_with_same_name = @form.field_named(name, CheckboxField)
|
||||
|
||||
if checkbox_with_same_name.to_param.blank?
|
||||
super
|
||||
|
@ -11,14 +11,9 @@ module Webrat
|
||||
@fields = nil
|
||||
end
|
||||
|
||||
def field(locator, *field_types)
|
||||
field_with_id(locator, *field_types) ||
|
||||
field_named(locator, *field_types) ||
|
||||
field_labeled(locator, *field_types) ||
|
||||
nil
|
||||
end
|
||||
|
||||
def field_by_element(element, *field_types)
|
||||
return nil if element.nil?
|
||||
|
||||
if Webrat.configuration.parse_with_nokogiri?
|
||||
expected_path = element.path
|
||||
else
|
||||
@ -64,11 +59,6 @@ module Webrat
|
||||
@session.request_page(form_action, form_method, params)
|
||||
end
|
||||
|
||||
def field_with_id(id, *field_types)
|
||||
possible_fields = fields_by_type(field_types)
|
||||
possible_fields.detect { |possible_field| possible_field.matches_id?(id) }
|
||||
end
|
||||
|
||||
def field_named(name, *field_types)
|
||||
possible_fields = fields_by_type(field_types)
|
||||
possible_fields.detect { |possible_field| possible_field.matches_name?(name) }
|
||||
|
@ -46,12 +46,26 @@ module Webrat
|
||||
end
|
||||
end
|
||||
|
||||
def find_field_with_id(id, *field_types) #:nodoc:
|
||||
def field_by_element(element, *field_types)
|
||||
forms.detect_mapped do |form|
|
||||
form.field_with_id(id, *field_types)
|
||||
form.field_by_element(element, *field_types)
|
||||
end
|
||||
end
|
||||
|
||||
def find_field_with_id(id, *field_types) #:nodoc:
|
||||
field_elements = Webrat::XML.css_search(dom, "button", "input", "textarea", "select")
|
||||
|
||||
field_element = field_elements.detect do |field_element|
|
||||
if id.is_a?(Regexp)
|
||||
Webrat::XML.attribute(field_element, "id") =~ id
|
||||
else
|
||||
Webrat::XML.attribute(field_element, "id") == id.to_s
|
||||
end
|
||||
end
|
||||
|
||||
field_by_element(field_element)
|
||||
end
|
||||
|
||||
def find_select_option(option_text, id_or_name_or_label) #:nodoc:
|
||||
if id_or_name_or_label
|
||||
field = field(id_or_name_or_label, SelectField)
|
||||
|
Loading…
Reference in New Issue
Block a user