Sha256: 1ff6183742dfd20b79535e0a8dee3c46ef7575b76b7504426991b7f488d7e851

Contents?: true

Size: 645 Bytes

Versions: 17

Compression:

Stored size: 645 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
      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).new(self, :element => e)
      end
    end

  end # XpathSupport
end # Watir

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
watir-webdriver-0.2.0 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.2.0.dev2 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.2.0.dev lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.1.9 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.1.8 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.1.7 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.1.6 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.1.5 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.1.4 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.1.3 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.1.2 lib/watir-webdriver/xpath_support.rb
ayanko-watir-webdriver-0.1.1.1 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.1.1 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.1.0 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.0.9 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.0.8 lib/watir-webdriver/xpath_support.rb
watir-webdriver-0.0.7 lib/watir-webdriver/xpath_support.rb