Class: Watir::Locators::Row::SelectorBuilder::XPath

Inherits:
Element::SelectorBuilder::XPath show all
Defined in:
lib/watir/locators/row/selector_builder/xpath.rb

Constant Summary

Constants inherited from Element::SelectorBuilder::XPath

Element::SelectorBuilder::XPath::CAN_NOT_BUILD, Element::SelectorBuilder::XPath::LOCATOR

Constants included from Element::SelectorBuilder::XpathSupport

Element::SelectorBuilder::XpathSupport::LOWERCASE_LETTERS, Element::SelectorBuilder::XpathSupport::UPPERCASE_LETTERS

Instance Method Summary collapse

Methods included from Element::SelectorBuilder::XpathSupport

downcase, escape

Instance Method Details

#build(selector, scope_tag_name) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/watir/locators/row/selector_builder/xpath.rb', line 6

def build(selector, scope_tag_name)
  return super(selector) if selector.key?(:adjacent)

  index = selector.delete(:index)

  super(selector)
  common_string = @built.delete(:xpath)
  expressions = generate_expressions(scope_tag_name)
  expressions.map! { |e| "#{e}#{common_string}" } unless common_string.empty?

  xpath = expressions.join(' | ').to_s

  @built[:xpath] = index ? add_index(xpath, index) : xpath
  @built
end