What is XPath and its types?
XPath or XML Path, is one of the most widely used locators in Selenium WebDriver for navigating around a page’s HTML structure. It can be used to locate any element in an HTML or XML document by using HTML DOM structure.
Syntax: XPath = //tagname[@Attribute=’Value’]
Different types of XPath -
Absolute XPath: It is the easiest method to locate the element. However, if any modifications are made to the element’s path, the XPath fails.
Syntax: /html//div/div/div/div[1]/div/a/img
Relative XPath: It begins in the midst of the HTML DOM structure with a double forward slash, implying that it can search for the element everywhere on the webpage.
Syntax: //img[@alt=‘LambdaTest’]