Module: Watir::XpathSupport
Instance Method Summary collapse
-
#element_by_xpath(xpath) ⇒ Object
Find the first element matching the given XPath.
-
#elements_by_xpath(xpath) ⇒ Object
Find all elements matching the given XPath.
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 |