Class: Webrat::Locators::FieldNamedLocator

Inherits:
Locator show all
Defined in:
lib/webrat/core/locators/field_named_locator.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from Locator

#initialize, #locate!

Constructor Details

This class inherits a constructor from Webrat::Locators::Locator

Instance Method Details

#error_messageObject



30
31
32
# File 'lib/webrat/core/locators/field_named_locator.rb', line 30

def error_message
  "Could not find field named #{@value.inspect}"
end

#field_elementObject



12
13
14
15
16
# File 'lib/webrat/core/locators/field_named_locator.rb', line 12

def field_element
  field_elements.detect do |field_element|
    field_element["name"] == @value.to_s
  end
end

#field_elementsObject



18
19
20
# File 'lib/webrat/core/locators/field_named_locator.rb', line 18

def field_elements
  @dom.xpath(*xpath_searches)
end

#locateObject



8
9
10
# File 'lib/webrat/core/locators/field_named_locator.rb', line 8

def locate
  Field.load(@session, field_element)
end

#xpath_searchesObject



22
23
24
25
26
27
28
# File 'lib/webrat/core/locators/field_named_locator.rb', line 22

def xpath_searches
  if @field_types.any?
    @field_types.map { |field_type| field_type.xpath_search }.flatten
  else
    Field.xpath_search
  end
end