--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/O5inSY0k5YwJ.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.
XPath is a tool. Every tool has purposes it’s useful for, and purposes for which it is commonly misused. Lock picks allow locksmiths to let you in when you left your keys in the coat you lent to the pretty girl in a strapless dress on a cold winter evening (trust me), but they also allow people to break in to your house and steal your TV. Part of being a professional is being able to judge which of the many tools in your toolkit are appropriate for the task at hand. I own a variety of hammers, because a baby sledge makes a poor (but satisfying!) tack hammer, and a drywall hammer is does a nice job of dimpling wallboard so the nails can be hidden.
XPath selectors can climb back up the tree, with its “/../” construct, something most other selectors (including CSS) can’t. They can include Boolean logic within predicates (e.g., “[@x=’y’ or @a=’b’]”), which is also unusual (although CSS can do it for limited combinations). They can reference the content of an element (e.g., via the “text()” and “.” constructs), which real CSS can’t (although some JavaScript CSS libraries can help). The list goes on and on.
Ross