Use FieldNamedLocator in form
This commit is contained in:
parent
522bb3272f
commit
260ef1ae4e
@ -65,10 +65,6 @@ module Webrat
|
|||||||
Webrat::XML.attribute(@element, "id")
|
Webrat::XML.attribute(@element, "id")
|
||||||
end
|
end
|
||||||
|
|
||||||
def matches_name?(name)
|
|
||||||
Webrat::XML.attribute(@element, "name") == name.to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
def disabled?
|
def disabled?
|
||||||
@element.attributes.has_key?("disabled") && Webrat::XML.attribute(@element, "disabled") != 'false'
|
@element.attributes.has_key?("disabled") && Webrat::XML.attribute(@element, "disabled") != 'false'
|
||||||
end
|
end
|
||||||
|
@ -2,6 +2,7 @@ require "webrat/core/elements/field"
|
|||||||
require "webrat/core_extensions/blank"
|
require "webrat/core_extensions/blank"
|
||||||
|
|
||||||
require "webrat/core/elements/element"
|
require "webrat/core/elements/element"
|
||||||
|
require "webrat/core/locators/field_named_locator"
|
||||||
|
|
||||||
module Webrat
|
module Webrat
|
||||||
class Form < Element #:nodoc:
|
class Form < Element #:nodoc:
|
||||||
@ -28,12 +29,15 @@ module Webrat
|
|||||||
end
|
end
|
||||||
|
|
||||||
def field_named(name, *field_types)
|
def field_named(name, *field_types)
|
||||||
possible_fields = fields_by_type(field_types)
|
Webrat::Locators::FieldNamedLocator.new(@session, dom, name, *field_types).locate
|
||||||
possible_fields.detect { |possible_field| possible_field.matches_name?(name) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
def dom
|
||||||
|
Webrat::XML.xpath_at(@session.dom, path)
|
||||||
|
end
|
||||||
|
|
||||||
def fields_by_type(field_types)
|
def fields_by_type(field_types)
|
||||||
if field_types.any?
|
if field_types.any?
|
||||||
fields.select { |f| field_types.include?(f.class) }
|
fields.select { |f| field_types.include?(f.class) }
|
||||||
|
Loading…
Reference in New Issue
Block a user