Skip to content

Commit

Permalink
Use FieldNamedLocator in form
Browse files Browse the repository at this point in the history
  • Loading branch information
brynary committed Nov 30, 2008
1 parent 522bb32 commit 260ef1a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 0 additions & 4 deletions lib/webrat/core/elements/field.rb
Expand Up @@ -64,10 +64,6 @@ def label_text
def id
Webrat::XML.attribute(@element, "id")
end

def matches_name?(name)
Webrat::XML.attribute(@element, "name") == name.to_s
end

def disabled?
@element.attributes.has_key?("disabled") && Webrat::XML.attribute(@element, "disabled") != 'false'
Expand Down
8 changes: 6 additions & 2 deletions lib/webrat/core/elements/form.rb
Expand Up @@ -2,6 +2,7 @@
require "webrat/core_extensions/blank"

require "webrat/core/elements/element"
require "webrat/core/locators/field_named_locator"

module Webrat
class Form < Element #:nodoc:
Expand All @@ -28,12 +29,15 @@ def submit
end

def field_named(name, *field_types)
possible_fields = fields_by_type(field_types)
possible_fields.detect { |possible_field| possible_field.matches_name?(name) }
Webrat::Locators::FieldNamedLocator.new(@session, dom, name, *field_types).locate
end

protected

def dom
Webrat::XML.xpath_at(@session.dom, path)
end

def fields_by_type(field_types)
if field_types.any?
fields.select { |f| field_types.include?(f.class) }
Expand Down

0 comments on commit 260ef1a

Please sign in to comment.