Created
November 6, 2015 01:54
-
-
Save unclebean/9a040bc34af2d62d7bbe to your computer and use it in GitHub Desktop.
Get elements with XPath in javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This function is from http://stackoverflow.com/questions/10596417/is-there-a-way-to-get-element-by-xpath-using-javascript-in-selenium-webdriver | |
function getElementByXpath(path) { | |
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
} | |
console.log( getElementByXpath("//*[contains(text(), 'test')]")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment