Sha256: c6af429e67c28ab3d8811325f2926316b6f06df240a1030c9c95eccbffe22000

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

module Watir
  module Locators
    class Button
      class Matcher < Element::Matcher
        def elements_match?(element, values_to_match)
          copy_values_to_match = values_to_match.dup
          value = copy_values_to_match.delete(:value)

          if value
            matching = matches_values?(fetch_value(element, :text), value)
            deprecate_value_button if matching

            matching ||= matches_values?(fetch_value(element, :value), value)

            return false unless matching
            return true if copy_values_to_match.empty?
          end

          super(element, copy_values_to_match)
        end

        def deprecate_value_button
          Watir.logger.deprecate(':value locator key for finding button text',
                                 'use :text locator',
                                 ids: [:value_button])
        end

        def validate_tag(element, _tag_name)
          tag_name = element.tag_name.downcase
          return unless %w[input button].include?(tag_name)

          # TODO: - Verify this is desired behavior based on https://bugzilla.mozilla.org/show_bug.cgi?id=1290963
          return if tag_name == 'input' && !Watir::Button::VALID_TYPES.include?(element.attribute('type').downcase)

          element
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
watir-6.16.1 lib/watir/locators/button/matcher.rb
watir-6.16.0 lib/watir/locators/button/matcher.rb