Sha256: fe4016ad0d10d1dac060c2f459df8f05283a6fb06ccd2947a2337a38a71f957a

Contents?: true

Size: 975 Bytes

Versions: 11

Compression:

Stored size: 975 Bytes

Contents

# encoding: utf-8
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

11 entries across 11 versions & 1 rubygems

Version Path
watir-webdriver-0.7.0 lib/watir-webdriver/container.rb
watir-webdriver-0.6.11 lib/watir-webdriver/container.rb
watir-webdriver-0.6.10 lib/watir-webdriver/container.rb
watir-webdriver-0.6.9 lib/watir-webdriver/container.rb
watir-webdriver-0.6.8 lib/watir-webdriver/container.rb
watir-webdriver-0.6.7 lib/watir-webdriver/container.rb
watir-webdriver-0.6.6 lib/watir-webdriver/container.rb
watir-webdriver-0.6.5 lib/watir-webdriver/container.rb
watir-webdriver-0.6.4 lib/watir-webdriver/container.rb
watir-webdriver-0.6.3 lib/watir-webdriver/container.rb
watir-webdriver-0.6.2 lib/watir-webdriver/container.rb