How can we locate the anchor element using their text in XPath?

less than 1 minute read

Below code, snippets help you to find the anchor element using its text in XPath and the sample code to use it in the selenium.

HTML:
<a href='order.html'>Order Lookup</a>

XPath:
//a[text()='Order Lookup']

Selenium find element:
driver.FindElement(By.XPath("//a[text()='Order Lookup']"));

Leave a comment