Find Elements
Commands to find elements within the context of another element.
Last updated
Commands to find elements within the context of another element.
Last updated
The Element class provides 5 main ways to find elements:
get a single element by TEXT
find a list of elements by CSS
find a list of elements by XPATH
get a single element by CSS
get a single element by XPATH
These are very similar to how py finds elements. For example, the following code snippet will search the entire DOM (aka webpage) for the first Element with id=name
and type "Carlos Kidman" into it.
Now take a look at the next code snippet:
This starts by searching the entire DOM for an element with class=form
. Then, within the form element, search for the first element with id=city
and type "Salt Lake City" into it.
Also, you can hold Element and Elements in variables instead of chaining them like the snippet above. The ability to set this context with a smaller scope can be powerful!