Sha256: c54a15ca8e0d23c764b08fd574f3d4edf9c9b3799fcc119dc257faafe6e65e5d

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

module Watir
  module Locators
    class TextField
      class Locator < Element::Locator
        def locate_all
          find_all_by_multiple
        end

        private

        def wd_find_first_by(how, what)
          how, what = selector_builder.build_wd_selector(how => what) if how == :tag_name
          super
        end

        def matches_selector?(element, rx_selector)
          rx_selector = rx_selector.dup

          tag_name = element.tag_name.downcase

          [:text, :value, :label].each do |key|
            if rx_selector.key?(key)
              correct_key = tag_name == 'input' ? :value : :text
              rx_selector[correct_key] = rx_selector.delete(key)
            end
          end

          super
        end

        def by_id
          element = super

          if element && !Watir::TextField::NON_TEXT_TYPES.include?(element.attribute(:type))
            if element.tag_name.downcase == 'textarea'
              warn "Locating textareas with '#text_field' is deprecated. Please, use '#textarea' method instead."
            end
            element
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
watir-webdriver-0.9.9 lib/watir-webdriver/locators/text_field/locator.rb
watir-6.0.0.beta5 lib/watir/locators/text_field/locator.rb
watir-6.0.0.beta4 lib/watir/locators/text_field/locator.rb
watir-6.0.0.beta3 lib/watir/locators/text_field/locator.rb
watir-6.0.0.beta2 lib/watir/locators/text_field/locator.rb
watir-6.0.0.beta1 lib/watir/locators/text_field/locator.rb
watir-webdriver-0.9.3 lib/watir-webdriver/locators/text_field/locator.rb