Question: why use xpath in selenium?
Answer: XPath enables testers to navigate through the XML structure of any document, and this can be used on both HTML and XML documents. ... While other locators in Selenium which search for elements using tags or CSS class names are simpler to use, they may not be sufficient to select all DOM elements of an HTML document.