Sha256: 53d18f30fcf01f13fbbbbe55f5560523b3d43aeff70ee082f519766d55e04284

Contents?: true

Size: 737 Bytes

Versions: 1

Compression:

Stored size: 737 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).new(self, :element, e)
    rescue WebDriver::Error::WebDriverError
      BaseElement.new(self, :xpath, xpath)
    end

    #
    # Find all elements matching the given XPath
    #

    def elements_by_xpath(xpath)
      # TODO: find the correct element class
      wd.find_elements(:xpath, xpath).map do |e|
        Watir.element_class_for(e.tag_name).new(self, :element, e)
      end
    rescue WebDriver::Error::WebDriverError
      []
    end

  end # XpathSupport
end # Watir

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
watir-webdriver-0.0.1.dev5 lib/watir-webdriver/xpath_support.rb