Sha256: 79edb261c3603bf052eca29934fffe098642382e6bd8f2954aed35078f747273

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

module Watir
  module Locators
    class Option
      class SelectorBuilder
        class XPath < Element::SelectorBuilder::XPath
          private

          def attribute_string
            result = if @selector.key?(:any)
                       to_match = @selector.delete :any
                       value = process_attribute(:value, to_match)
                       text = process_attribute(:text, to_match)
                       label = process_attribute(:label, to_match)
                       "[#{value} or #{text} or #{label}]"
                     else
                       ''
                     end

            attributes = @selector.keys.map { |key|
              process_attribute(key, @selector.delete(key))
            }.flatten.compact
            attribute_values = attributes.empty? ? '' : "[#{attributes.join(' and ')}]"
            "#{result}#{attribute_values}"
          end

          def add_to_matching(key, regexp, results = nil)
            return unless results.nil? || requires_matching?(results, regexp)

            return super unless %i[value text label].include? key

            @built[:any] = regexp
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
watir-7.1.0 lib/watir/locators/option/selector_builder/xpath.rb
watir-7.0.0 lib/watir/locators/option/selector_builder/xpath.rb
watir-7.0.0.beta5 lib/watir/locators/option/selector_builder/xpath.rb
watir-7.0.0.beta4 lib/watir/locators/option/selector_builder/xpath.rb
watir-7.0.0.beta3 lib/watir/locators/option/selector_builder/xpath.rb
watir-7.0.0.beta2 lib/watir/locators/option/selector_builder/xpath.rb