Now that we have seen the basic definitions of XPaths and CSS and also looked at what WebElements are, let's understand how we can use these to exploit the DOM. DOM traversal entails getting to the desired element with the help of either XPaths or CSS. It is possible to traverse the DOM in a forward and backward direction with XPaths but traversal through XPaths is slow compared to CSS. Traversal using CSS can only be done in the forward direction. In order to traverse the DOM, using either XPaths or CSS, we need to understand the By class.
DOM traversal
Dissecting the By class
The By class is an abstract class that has eight static methods and eight inner classes. Let's understand the structure of the By class.
...