Class: Watir::Locators::Button::SelectorBuilder

Inherits:
Element::SelectorBuilder show all
Defined in:
lib/watir-webdriver/locators/button/selector_builder.rb,
lib/watir-webdriver/locators/button/selector_builder/xpath.rb

Defined Under Namespace

Classes: XPath

Constant Summary

Constants inherited from Element::SelectorBuilder

Element::SelectorBuilder::VALID_WHATS, Element::SelectorBuilder::WILDCARD_ATTRIBUTE

Instance Method Summary collapse

Methods inherited from Element::SelectorBuilder

#build, #check_type, #initialize, #normalized_selector, #should_use_label_element?, #xpath_builder

Constructor Details

This class inherits a constructor from Watir::Locators::Element::SelectorBuilder

Instance Method Details

#build_wd_selector(selectors) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/watir-webdriver/locators/button/selector_builder.rb', line 5

def build_wd_selector(selectors)
  return if selectors.values.any? { |e| e.kind_of? Regexp }

  selectors.delete(:tag_name) || raise("internal error: no tag_name?!")

  button_attr_exp = xpath_builder.attribute_expression(:button, selectors)

  selectors[:type] = Watir::Button::VALID_TYPES
  input_attr_exp = xpath_builder.attribute_expression(:input, selectors)

  xpath = ".//button"
  xpath << "[#{button_attr_exp}]" unless button_attr_exp.empty?
  xpath << " | .//input"
  xpath << "[#{input_attr_exp}]"

  p build_wd_selector: xpath if $DEBUG

  [:xpath, xpath]
end