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

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

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
24
25
# File 'lib/watir-webdriver/locators/row/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?!")

  expressions = %w[./tr]
  unless %w[tbody tfoot thead].include?(@parent.tag_name.downcase)
    expressions += %w[./tbody/tr ./thead/tr ./tfoot/tr]
  end

  attr_expr = xpath_builder.attribute_expression(nil, selectors)

  unless attr_expr.empty?
    expressions.map! { |e| "#{e}[#{attr_expr}]" }
  end

  xpath = expressions.join(" | ")

  p build_wd_selector: xpath if $DEBUG

  [:xpath, xpath]
end