Introducing - the DOM
No, not that one...
If you are into UI automation like myself, then you probably heard about this DOM thingy everyone is talking about, right?
Well, In this article we are going to take a slightly deeper look into what is known as the Document Object Model.
A quick introduction
Quite often we address the DOM in terms of the page source of our AUT (Application under test). But, DOM is actually a language -independant interface for treating XML and HTML documents. That Interface offers the document as a tree of objects.
Well, we are into the Test-Automation stuff, so let's stick to the HTML part.
In the WEB world, the DOM would be referred to as the browsers programatic representation of the web page. An API if you will, for dealing with and manipulating the HTML without actually going in and changing it manually. The interface specification is standartized by the W3C.
Let's dive deeper...
In the document object model, everything is assembled from "nodes". These nodes are objects that have properties, and they have a structure of a tree.
The node objects are divided into types. There are several types, but for now let's stick to these 4:
DocumentType - Which in our case is HTML.
Element - Probably the most common node type which represents the HTML elements of the page.
Text - Text nodes are text values that are often found inside of HTML tags or as attributes.