Class: WatirNokogiri::ButtonLocator
Constant Summary
ElementLocator::VALID_WHATS
Instance Method Summary
collapse
#assert_valid_as_attribute, #attribute_expression, #build_xpath, #can_be_combined_with_css?, #can_be_combined_with_xpath?, #check_type, #delete_regexps_from, #fetch_value, #find_by_regexp_selector, #given_css, #given_xpath, #initialize, #label_from_text, #locate, #locate_all, #matches_selector?, #normalize_selector, #normalized_selector, #should_use_label_element?, #valid_attribute?
Instance Method Details
#build_nokogiri_selector(selectors) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/watir-nokogiri/locators/button_locator.rb', line 4
def build_nokogiri_selector(selectors)
return if selectors.values.any? { |e| e.kind_of? Regexp }
selectors.delete(:tag_name) || raise("internal error: no tag_name?!")
@building = :button
button_attr_exp = attribute_expression(selectors)
@building = :input
selectors[:type] = Button::VALID_TYPES
input_attr_exp = attribute_expression(selectors)
xpath = ".//button"
xpath << "[#{button_attr_exp}]" unless button_attr_exp.empty?
xpath << " | .//input"
xpath << "[#{input_attr_exp}]"
p :build_nokogiri_selector => xpath if $DEBUG
[:xpath, xpath]
end
|
#equal_pair(key, value) ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'lib/watir-nokogiri/locators/button_locator.rb', line 34
def equal_pair(key, value)
if @building == :button && key == :value
text = XpathSupport.escape(value)
"(text()=#{text} or @value=#{text})"
else
super
end
end
|
#lhs_for(key) ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/watir-nokogiri/locators/button_locator.rb', line 26
def lhs_for(key)
if @building == :input && key == :text
"@value"
else
super
end
end
|
#tag_name_matches?(tag_name, _) ⇒ Boolean
44
45
46
|
# File 'lib/watir-nokogiri/locators/button_locator.rb', line 44
def tag_name_matches?(tag_name, _)
!!(/^(input|button)$/ === tag_name)
end
|
#validate_element(element) ⇒ Object
48
49
50
51
|
# File 'lib/watir-nokogiri/locators/button_locator.rb', line 48
def validate_element(element)
return if element.node_name.downcase == "input" && !Button::VALID_TYPES.include?(element.get_attribute(:type).downcase)
super
end
|