Sha256: b27bc68a4443a09cd2b7f4fa21f747adffafb3345afa38fa14fc3382e03797c5

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

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

4 entries across 4 versions & 1 rubygems

Version Path
watir-7.3.0 lib/watir/locators/option/selector_builder/xpath.rb
watir-7.2.2 lib/watir/locators/option/selector_builder/xpath.rb
watir-7.2.1 lib/watir/locators/option/selector_builder/xpath.rb
watir-7.2.0 lib/watir/locators/option/selector_builder/xpath.rb