Class: Watir::Locators::TextField::SelectorBuilder

Inherits:
Element::SelectorBuilder show all
Defined in:
lib/watir-webdriver/locators/text_field/selector_builder.rb,
lib/watir-webdriver/locators/text_field/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
# File 'lib/watir-webdriver/locators/text_field/selector_builder.rb', line 5

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

  selectors.delete(:tag_name)

  textarea_attr_exp = xpath_builder.attribute_expression(:textarea, selectors)
  input_attr_exp = xpath_builder.attribute_expression(:input, selectors)

  xpath = ".//input[(not(@type) or (#{negative_type_expr}))"
  xpath << " and #{input_attr_exp}" unless input_attr_exp.empty?
  xpath << "] "
  xpath << "| .//textarea"
  xpath << "[#{textarea_attr_exp}]" unless textarea_attr_exp.empty?

  p build_wd_selector: xpath if $DEBUG

  [:xpath, xpath]
end