Sha256: cda39dfb1339c4af9a7f244ad8b8c990df7b78e5cf6c763030af68840e1c08d1

Contents?: true

Size: 951 Bytes

Versions: 34

Compression:

Stored size: 951 Bytes

Contents

module Watir
  module Container
    include XpathSupport
    include Atoms

    #
    # 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

34 entries across 34 versions & 2 rubygems

Version Path
watir-6.7.3 lib/watir/container.rb
watir-6.7.2 lib/watir/container.rb
watir-6.7.1 lib/watir/container.rb
watir-6.7.0 lib/watir/container.rb
watir-6.6.3 lib/watir/container.rb
watir-6.6.2 lib/watir/container.rb
watir-6.6.1 lib/watir/container.rb
watir-6.6.0 lib/watir/container.rb
watir-6.5.0 lib/watir/container.rb
watir-6.4.3 lib/watir/container.rb
watir-6.4.2 lib/watir/container.rb
watir-6.4.1 lib/watir/container.rb
watir-6.4.0 lib/watir/container.rb
watir-6.4.0.rc2 lib/watir/container.rb
watir-6.4.0.rc1 lib/watir/container.rb
watir-6.3.0 lib/watir/container.rb
watir-6.2.1 lib/watir/container.rb
watir-6.2.0 lib/watir/container.rb
watir-6.1.0 lib/watir/container.rb
watir-6.0.3 lib/watir/container.rb