TEEHSTAEHC HTAPX
RELATIVE PARENT - CHILD
XPath pattern based on the XPath pattern based on the
attribute / text (grand) parent to (grand)
child relationships
ATTRIBUTE
//tagName[@attibute='value']
PARENT TO CHILD
(xpath of parent)/child-tagName
TEXT
//tagName[text()='value']
CHILD TO PARENT
(xpath of child)/parent::parent-tagName
PARTIAL ATTRIBUTE
//tagName[contains(@attibute,'value')]
CHILD TO GRAND PARENT
(xpath of child)/ancestor::ancestor-tagName
PARTIAL TEXT
//tagName[contains(text(),'value')]
GRAND PARENT TO CHILD
(xpath of ancestor)//child-tagName
LAST CHILD
(xpath of parent)/child-tagName[last()]
COLLECTION
XPath pattern based on the
indexes with(out) relations.
Note: index starts at 1
AXES
USING ITEM INDEX XPath pattern based on the
(xpath)[index] sibling & Cousin relatiionships
USING CHILD ITEM INDEX YOUNGER SIBLING
(parent-xpath)/child-tagName[index] (xpath)/following-sibling::sibling-tagName
USING AND CONDITION ELDER SIBLING
//tagName[@att1='v1' and @att2='v2'] (xpath)/preceding-sibling::sibling-tagName
USING OR CONDITION
//tagName[@att1='v1' or @att2='v2'] YOUNGER COUSIN
(xpath)/following::cousin-tagName
ELDER COUSIN
(xpath)/preceding::cousin-tagName
Use Ruto, the opensource xpath
finder if you find difficult to write
your own xpaths.
It is available as Chrome, Firefox,
www.testleaf.com
Edge extensions