function getElementByXpath(path) { return document.evaluate( path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; } getElementByXpath('(//div[@class="font-bold btn"])[1]')