Sha256: 8b0b1e70abd563316df1efa9a0d92cb0495cdb440075692f8c7b5cc2b05336a2

Contents?: true

Size: 832 Bytes

Versions: 1

Compression:

Stored size: 832 Bytes

Contents

module Watir
  module Locators
    class TextField
      class SelectorBuilder < Element::SelectorBuilder
        def build_wd_selector(selectors)
          return if selectors.values.any? { |e| e.is_a? Regexp }

          selectors.delete(:tag_name)

          input_attr_exp = xpath_builder.attribute_expression(:input, selectors)

          xpath = ".//input[(not(@type) or (#{negative_type_expr}))"
          xpath << " and #{input_attr_exp}" unless input_attr_exp.empty?
          xpath << ']'

          p build_wd_selector: xpath if $DEBUG

          [:xpath, xpath]
        end

        private

        def negative_type_expr
          Watir::TextField::NON_TEXT_TYPES.map { |type|
            format('%s!=%s', XpathSupport.downcase('@type'), type.inspect)
          }.join(' and ')
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
watir-6.14.0 lib/watir/locators/text_field/selector_builder.rb