Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

46 lines (35 sloc) 0.942 kb
require "webrat/core/locators/locator"
module Webrat
module Locators
class FieldNamedLocator < Locator # :nodoc:
def locate
Field.load(@session, field_element)
end
def field_element
field_elements.detect do |field_element|
if @value.is_a?(Regexp)
field_element["name"] =~ @value
else
field_element["name"] == @value.to_s
end
end
end
def field_elements
@dom.xpath(*xpath_searches)
end
def xpath_searches
if @field_types.any?
@field_types.map { |field_type| field_type.xpath_search }.flatten
else
Field.xpath_search
end
end
def error_message
"Could not find field named #{@value.inspect}"
end
end
def field_named(name, *field_types)
FieldNamedLocator.new(@session, dom, name, *field_types).locate!
end
end
end
Jump to Line
Something went wrong with that request. Please try again.