Professional Documents
Culture Documents
XPathPPT Mahendra
XPathPPT Mahendra
XPathPPT Mahendra
by- Mahendra
Xpath is Locator:
o Locators are used to identify web element on the UI Page.
8 Locators in Selenium:
What is XPATH ? Selenium has 8 locators namely, ID, Name, xpath, cssSelector,
linkText, PartialLinkText,TagName, ClassName
2
What Are The Types Of
Xpath?
◦ It Starts with / single slash
◦ Locates The Element from Root
Element
Absolute
◦ Long, Timing consuming, complex,
Xpath
error prone
◦ /html[1]/body[1]/div[1]/div[2]/div[1]/
img[1]
4
◦ It Starts with // double slash
◦ Directly refer to element
Relative Xpath ◦ Small in size as compared to Absolute
xpath
5
“
◦ How to write a Xpath
Expression ?
6
◦ Basic Expression: XPath =//tagname[@Attribute=’Value’]
7
What are Xpath axes?
Following: This indicates all the nodes that appear after the context node in the HTML DOM structure.
Following-sibling: This one indicates all the sibling nodes (same parent as context node)
that appear after the context node in the HTML DOM structure.
Preceding: This indicates all the nodes that appear before the context node in the HTML DOM structure.
Preceding-sibling: This one indicates all the sibling nodes (same parent as context node) that
appear before the context node in the HTML DOM structure.
Child: This indicates the children of the context node.
Parent: This indicates the parent of the context node.
descendant: This indicates the children, and grandchildren and their children (if any) of the context node.
Ancestor: This axes indicates all the ancestors relative to the context node, also reaching up to the root
node.