Module: Watir::XpathSupport

Includes:
Selenium
Included in:
Container
Defined in:
lib/watir-webdriver/xpath_support.rb

Instance Method Summary collapse

Instance Method Details

#element_by_xpath(xpath) ⇒ Object

Find the first element matching the given XPath


10
11
12
13
14
15
# File 'lib/watir-webdriver/xpath_support.rb', line 10

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

#elements_by_xpath(xpath) ⇒ Object

Find all elements matching the given XPath


21
22
23
24
25
# File 'lib/watir-webdriver/xpath_support.rb', line 21

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