Last active
February 27, 2019 15:37
-
-
Save bastman/111079dc709704470209fa60d13d10fb to your computer and use it in GitHub Desktop.
e2e-html-dom-selectors-xpath
This file contains hidden or 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
document.querySelector('#region > div > div:nth-child(1) > span') | |
in chrome dev tools you can execute: | |
$x('//*[@id="region"]/div/div[1]/span') | |
which should be similar to ... | |
function getElementByXpath(path) { | |
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
} | |
getElementByXpath('//*[@id="region"]/div/div[1]/span') | |
see: https://stackoverflow.com/questions/10596417/is-there-a-way-to-get-element-by-xpath-using-javascript-in-selenium-webdriver | |
you may want to install ChroPath extension: https://chrome.google.com/webstore/detail/chropath/ljngjbnaijcbncmcnjfhigebomdlkcjo/related?hl=en |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment