Class: Webrat::Locators::LabelLocator

Inherits:
Locator show all
Defined in:
lib/webrat/core/locators/label_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

#label_elementObject


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

def label_element
  label_elements.detect do |label_element|
    text(label_element) =~ /^\W*#{Regexp.escape(@value.to_s)}(\b|\Z)/i
  end
end

#label_elementsObject


19
20
21
# File 'lib/webrat/core/locators/label_locator.rb', line 19

def label_elements
  @dom.xpath(*Label.xpath_search)
end

#locateObject


9
10
11
# File 'lib/webrat/core/locators/label_locator.rb', line 9

def locate
  Label.load(@session, label_element)
end

#text(label_element) ⇒ Object


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

def text(label_element)
  str = label_element.inner_text
  str.gsub!("\n","")
  str.strip!
  str.squeeze!(" ")
  str
end