Is there a way to get element by XPath using JavaScript in Selenium WebDriver?

You can use document.evaluate: Evaluates an XPath expression string and returns a result of the specified type if possible. It is w3-standardized and whole documented: https://developer.mozilla.org/en-US/docs/Web/API/Document.evaluate Expand snippet There’s also a great introduction on mozilla developer network: https://developer.mozilla.org/en-US/docs/Introduction_to_using_XPath_in_JavaScript#document.evaluate Alternative version, using XPathEvaluator: Show code snippet