Sha256: ca695cbc5d32e6e7b173685cff421f8cdd62ed2aef51ee25cb03847f28a2bccd

Contents?: true

Size: 1.35 KB

Versions: 11

Compression:

Stored size: 1.35 KB

Contents

module Watir
  module Locators
    class TextField
      class SelectorBuilder
        class XPath < Element::SelectorBuilder::XPath
          def text_string
            return super if @adjacent

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

          def additional_string
            return '' if @adjacent

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

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

          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

          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
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
watir-7.1.0 lib/watir/locators/text_field/selector_builder/xpath.rb
watir-7.0.0 lib/watir/locators/text_field/selector_builder/xpath.rb
watir-7.0.0.beta5 lib/watir/locators/text_field/selector_builder/xpath.rb
watir-7.0.0.beta4 lib/watir/locators/text_field/selector_builder/xpath.rb
watir-7.0.0.beta3 lib/watir/locators/text_field/selector_builder/xpath.rb
watir-7.0.0.beta2 lib/watir/locators/text_field/selector_builder/xpath.rb
watir-7.0.0.beta1 lib/watir/locators/text_field/selector_builder/xpath.rb
watir-6.19.1 lib/watir/locators/text_field/selector_builder/xpath.rb
watir-6.19.0 lib/watir/locators/text_field/selector_builder/xpath.rb
watir-6.18.0 lib/watir/locators/text_field/selector_builder/xpath.rb
watir-6.17.0 lib/watir/locators/text_field/selector_builder/xpath.rb