Class: Webrat::Locators::LabelLocator
- Inherits:
-
Locator
show all
- Defined in:
- lib/webrat/core/locators/label_locator.rb
Overview
Instance Method Summary
collapse
Methods inherited from Locator
#initialize, #locate!
Instance Method Details
#label_element ⇒ Object
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_elements ⇒ Object
19
20
21
|
# File 'lib/webrat/core/locators/label_locator.rb', line 19
def label_elements
@dom.xpath(*Label.xpath_search)
end
|
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
|