Sha256: 02c7dc5038422577e58ba728d68fdfd6bdc19741940b39c6ee7f76ca3cf1859d

Contents?: true

Size: 964 Bytes

Versions: 17

Compression:

Stored size: 964 Bytes

Contents

# encoding: utf-8
module Watir
  module Container
    include XpathSupport

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

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

    private

    def browserbot(function_name, *arguments)
      script = browserbot_script + "return browserbot.#{function_name}.apply(browserbot, arguments);"
      driver.execute_script(script, *arguments)
    end

    def browserbot_script
      @browserbot_script ||= File.read("#{File.dirname(__FILE__)}/browserbot.js")
    end

    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

17 entries across 17 versions & 2 rubygems

Version Path
watir-webdriver-0.2.3 lib/watir-webdriver/container.rb
watir-webdriver-0.2.2 lib/watir-webdriver/container.rb
watir-webdriver-0.2.1 lib/watir-webdriver/container.rb
watir-webdriver-0.2.0 lib/watir-webdriver/container.rb
watir-webdriver-0.2.0.dev2 lib/watir-webdriver/container.rb
watir-webdriver-0.2.0.dev lib/watir-webdriver/container.rb
watir-webdriver-0.1.9 lib/watir-webdriver/container.rb
watir-webdriver-0.1.8 lib/watir-webdriver/container.rb
watir-webdriver-0.1.7 lib/watir-webdriver/container.rb
watir-webdriver-0.1.6 lib/watir-webdriver/container.rb
watir-webdriver-0.1.5 lib/watir-webdriver/container.rb
watir-webdriver-0.1.4 lib/watir-webdriver/container.rb
watir-webdriver-0.1.3 lib/watir-webdriver/container.rb
watir-webdriver-0.1.2 lib/watir-webdriver/container.rb
ayanko-watir-webdriver-0.1.1.1 lib/watir-webdriver/container.rb
watir-webdriver-0.1.1 lib/watir-webdriver/container.rb
watir-webdriver-0.1.0 lib/watir-webdriver/container.rb