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


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

def additional_string
  return '' if @adjacent

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

#negative_type_textObject


37
38
39
40
41
# File 'lib/watir/locators/text_field/selector_builder/xpath.rb', line 37

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

#tag_stringObject


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

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

#text_stringObject


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

def text_string
  return super if @adjacent

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

#type_string(type) ⇒ Object


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

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