What is the DOM?

The DOM is an application programming interface that is linked to HTML, XHTML, or XML documents and treats these similar to a tree where each node in the tree represents a part of the document.

In simple words, the DOM can be compared to a tree where there is a root node, intermediate nodes, and leaf nodes.

The root node has no parent; the intermediate nodes have a parent, one or more siblings, and one or more children. This is a very important concept and will help at the time of creating relative or customized XPaths, which we will see in a later part of the chapter.

Shown here is a sample DOM:

In the preceding diagram, ...

Get Selenium WebDriver Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.