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

Inherits:
Element::SelectorBuilder::XPath show all
Defined in:
lib/watir/locators/text_field/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 inherited from Element::SelectorBuilder::XPath

#build

Methods included from Element::SelectorBuilder::XpathSupport

downcase, escape

Instance Method Details

#additional_stringObject



15
16
17
18
19
# File 'lib/watir/locators/text_field/selector_builder/xpath.rb', line 15

def additional_string
  return '' if @adjacent

  type_string(@selector.delete(:type))
end

#negative_type_textObject



39
40
41
42
43
44
45
# File 'lib/watir/locators/text_field/selector_builder/xpath.rb', line 39

def negative_type_text
  Watir::TextField::NON_TEXT_TYPES.map { |type|
    lhs = lhs_for(:type, downcase: true)
    rhs = SelectorBuilder::XpathSupport.downcase(SelectorBuilder::XpathSupport.escape(type))
    "#{lhs}!=#{rhs}"
  }.join(' and ')
end

#tag_stringObject



21
22
23
24
# File 'lib/watir/locators/text_field/selector_builder/xpath.rb', line 21

def tag_string
  @selector[:tag_name] = 'input' unless @adjacent
  super
end

#text_stringObject



8
9
10
11
12
13
# File 'lib/watir/locators/text_field/selector_builder/xpath.rb', line 8

def text_string
  return super if @adjacent

  @built[:text] = @selector.delete(:text) if @selector.key?(:text)
  ''
end

#type_string(type) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/watir/locators/text_field/selector_builder/xpath.rb', line 26

def type_string(type)
  if type.eql?(true)
    "[#{negative_type_text}]"
  elsif Watir::TextField::NON_TEXT_TYPES.include?(type)
    msg = "TextField Elements can not be located by type: #{type}"
    raise LocatorException, msg
  elsif type.nil?
    "[not(@type) or (#{negative_type_text})]"
  else
    "[#{process_attribute(:type, type)}]"
  end
end