Sha256: b33c785bce60b98f87cdd588130320659db8d52a06e90dce725937c26254b90c

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 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))
            warn "Locating textareas with '#text_field' is deprecated. Please, use '#textarea' method instead."
            element
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
watir-webdriver-0.9.2 lib/watir-webdriver/locators/text_field/locator.rb