Sha256: 3ead98a8854bca216f9b04b62f82c62c2c6ce069051e91c7b0791cbd7e4c964b

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

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

          selectors.delete(:tag_name)

          textarea_attr_exp = xpath_builder.attribute_expression(:textarea, selectors)
          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 << "] "
          xpath << "| .//textarea"
          xpath << "[#{textarea_attr_exp}]" unless textarea_attr_exp.empty?

          p build_wd_selector: xpath if $DEBUG

          [:xpath, xpath]
        end

        private

        def negative_type_expr
          Watir::TextField::NON_TEXT_TYPES.map do |type|
            "%s!=%s" % [XpathSupport.downcase('@type'), type.inspect]
          end.join(' and ')
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

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