-
Selenium Element Locator
- identifier=id
- id=id
- name=name
- dom=javascriptExpression
- xpath=xpathExpression
- link=textPattern
- css=cssSelectorSyntax
-
What?
- XPath uses path expressions to navigate in XML documents
- XPath contains a library of standard functions
- XPath is a major element in XSLT
- XPath is a W3C recommendation
-
Nodes
-
types
- element
- attribute
- text
- namespace
- processing-instruction
- comment
- document nodes
-
relationship (tree)
- parent
- children
- siblings
- ancestors
- descendants
-
path expression
-
expressions
-
/
- Selects from the root node
-
//
- Selects nodes in the document from the current node that match the selection no matter where they are
-
.
- Selects the current node
-
..
- Selects the parent of the current node
-
@
- Selects attributes
-
Predicates
-
sequence
- /bookstore/book[1]
-
function
- /bookstore/book[last()]
-
attribute
- //title[@lang='eng']
-
sub element
- /bookstore/book[price>35.00]
-
logical operator
- /bookstore/book[price>35.00 and @type='WEB']
-
wildcards
-
*
- Matches any element node
-
@*
- Matches any attribute node
-
node()
- Matches any node of any kind
-
axes
- axisname::nodetest[predicate]
-
types
- ancestor
- following-sibling
- attribute
- etc...
-
operators
-
|
- //book/title | //book/price
-
and
- price>9.00 and price<9.90
- etc...