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


34
35
36
# File 'lib/webrat/core/locators/field_named_locator.rb', line 34

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

#field_elementObject


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

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

#field_elementsObject


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

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


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

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