Sha256: e64a439e54814cf5e5c4459af1da715a3c38a7550afe3d4245a38187cfe1a405

Contents?: true

Size: 700 Bytes

Versions: 7

Compression:

Stored size: 700 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::NoSuchElementError
      BaseElement.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).new(self, :element, e)
      end
    rescue WebDriver::Error::NoSuchElementError
      []
    end

  end # XpathSupport
end # Watir

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
watir-webdriver-0.0.6 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.0.5 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.0.4 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.0.3 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.0.2 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.0.1 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.0.1.dev7 lib/watir-webdriver/xpath_support.rb