Class: Webrat::Locators::ButtonLocator
- Inherits:
-
Locator
show all
- Defined in:
- lib/webrat/core/locators/button_locator.rb
Overview
Instance Method Summary
collapse
Methods inherited from Locator
#initialize, #locate!
Instance Method Details
12
13
14
15
16
17
18
19
20
|
# File 'lib/webrat/core/locators/button_locator.rb', line 12
def button_element
button_elements.detect do |element|
@value.nil? ||
matches_id?(element) ||
matches_value?(element) ||
matches_html?(element) ||
matches_alt?(element)
end
end
|
#error_message ⇒ Object
43
44
45
|
# File 'lib/webrat/core/locators/button_locator.rb', line 43
def error_message
"Could not find button #{@value.inspect}"
end
|
8
9
10
|
# File 'lib/webrat/core/locators/button_locator.rb', line 8
def locate
ButtonField.load(@session, button_element)
end
|
#matches_alt?(element) ⇒ Boolean
35
36
37
|
# File 'lib/webrat/core/locators/button_locator.rb', line 35
def matches_alt?(element)
Webrat::XML.attribute(element, "alt") =~ /^\W*#{Regexp.escape(@value.to_s)}/i
end
|
#matches_html?(element) ⇒ Boolean
31
32
33
|
# File 'lib/webrat/core/locators/button_locator.rb', line 31
def matches_html?(element)
Webrat::XML.inner_html(element) =~ /#{Regexp.escape(@value.to_s)}/i
end
|
#matches_id?(element) ⇒ Boolean
22
23
24
25
|
# File 'lib/webrat/core/locators/button_locator.rb', line 22
def matches_id?(element)
(@value.is_a?(Regexp) && Webrat::XML.attribute(element, "id") =~ @value) ||
(!@value.is_a?(Regexp) && Webrat::XML.attribute(element, "id") == @value.to_s)
end
|
#matches_value?(element) ⇒ Boolean
27
28
29
|
# File 'lib/webrat/core/locators/button_locator.rb', line 27
def matches_value?(element)
Webrat::XML.attribute(element, "value") =~ /^\W*#{Regexp.escape(@value.to_s)}/i
end
|