Sha256: f56e61b71967410a3af07244c1047880c97ccb0e9efeee9adf0192f25e148231

Contents?: true

Size: 663 Bytes

Versions: 3

Compression:

Stored size: 663 Bytes

Contents

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

    #
    # Find the first element matching the given XPath
    #

    def element_by_xpath(xpath)
      e = wd.find_element(:xpath, xpath)
      Watir.element_class_for(e.tag_name.downcase).new(self, :element => e)
    rescue WebDriver::Error::NoSuchElementError
      Element.new(self, :xpath => xpath)
    end

    #
    # Find all elements matching the given XPath
    #

    def elements_by_xpath(xpath)
      wd.find_elements(:xpath, xpath).map do |e|
        Watir.element_class_for(e.tag_name.downcase).new(self, :element => e)
      end
    end

  end # XpathSupport
end # Watir

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
watir-webdriver-0.2.3 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.2.2 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.2.1 lib/watir-webdriver/xpath_support.rb