Sha256: 82ce4b1778c4662ab362bab1e1e942e62959f36684ae6950a6bd861cc9511911

Contents?: true

Size: 915 Bytes

Versions: 2

Compression:

Stored size: 915 Bytes

Contents

# frozen_string_literal: true

module Watir
  module Locators
    class TextField
      class Matcher < Element::Matcher
        private

        def elements_match?(element, values_to_match)
          case fetch_value(element, :tag_name)
          when 'input'
            %i[text label visible_text].each do |key|
              next unless values_to_match.key?(key)

              values_to_match[:value] = values_to_match.delete(key)
            end
          when 'label'
            %i[value label].each do |key|
              next unless values_to_match.key?(key)

              values_to_match[:text] = values_to_match.delete(key)
            end
          else
            return
          end

          super
        end

        def validate_tag(element, _expected)
          tag_name = fetch_value(element, :tag_name)
          matches_values?(tag_name, 'input')
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
watir-7.2.2 lib/watir/locators/text_field/matcher.rb
watir-7.2.1 lib/watir/locators/text_field/matcher.rb