xpath cheet sheet

*Attributes are represented by "@" in XPath

the writing below is called descendant-or-self, and you can refer to all the dom elements of that html.

//img[contains(@class, 'image')]

Whether it can be taken with a perfect partial match.

//div[contains(text(), 'item')]

When you want to specify an element containing the characters “Product number” from this HTML. You can also use the not operator like

//img[not(contains(@src, ‘main’))]/@src


Gets the penultimate p element of that element as seen from the parent element.


Of all the elements, select the one that does not match the tag and content among all the elements before the child element. character *(“.”) in XPath is called the “context item expression” because it refers to the context item. All td elements are shown here.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store

information science & technology. threat hunting. Researcher of Internet Assigned Numbers Authority