Sha256: 27cc2df309f63ae9ef3d409a4a2b256b83797ef8fc8a04b8f8ae90c2c556d1d4

Contents?: true

Size: 956 Bytes

Versions: 13

Compression:

Stored size: 956 Bytes

Contents

module Watir
  module Container
    include XpathSupport
    include JSSnippets

    #
    # Returns element.
    #
    # @example
    #   browser.element(data_bind: 'func')
    #
    # @return [HTMLElement]
    #

    def element(*args)
      HTMLElement.new(self, extract_selector(args))
    end

    #
    # Returns element collection.
    #
    # @example
    #   browser.elements(data_bind: 'func')
    #
    # @return [HTMLElementCollection]
    #

    def elements(*args)
      HTMLElementCollection.new(self, extract_selector(args))
    end

    #
    # @api private
    #

    def extract_selector(selectors)
      case selectors.size
      when 2
        return { selectors[0] => selectors[1] }
      when 1
        obj = selectors.first
        return obj if obj.kind_of? Hash
      when 0
        return {}
      end

      raise ArgumentError, "expected Hash or (:how, 'what'), got #{selectors.inspect}"
    end

  end # Container
end # Watir

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
watir-6.11.0 lib/watir/container.rb
watir-6.11.0.beta2 lib/watir/container.rb
watir-6.11.0.beta1 lib/watir/container.rb
watir-6.10.3 lib/watir/container.rb
watir-6.10.2 lib/watir/container.rb
watir-6.10.0 lib/watir/container.rb
watir-6.9.1 lib/watir/container.rb
watir-6.9.0 lib/watir/container.rb
watir-6.8.4 lib/watir/container.rb
watir-6.8.3 lib/watir/container.rb
watir-6.8.2 lib/watir/container.rb
watir-6.8.1 lib/watir/container.rb
watir-6.8.0 lib/watir/container.rb