Objective: The DOM — the one idea every locator, assertion, and Page Object stands on.
⏱ ≈3 min full lesson · Converted from the B-02 module deck · English edition — Español · العربية · বাংলা in translation
In about 3 minutes: the DOM — the one idea every locator, assertion, and Page Object stands on.
The browser builds a tree: A page arrives as HTML — a structured document. The browser turns it into a live tree of elements called the DOM. Every heading, link, and button is a node in that tree — and a test can find any node and ask it questions.
Five element types run everything: Headings, links, buttons, input fields, and blocks of text. Nearly everything a test does is: find one of these five, then check it or use it. If you can name what you're looking at, you can locate it.
A real locator, from a real suite: Read it as English: “on the page, find the first top-level heading.” This is how the aomaai.com suite's HomePage finds its main heading — no magic, just the DOM being questioned. Code: page.locator("h1").first()
Plug & chug: do the inventory: Open any web page. Count: headings __, links __, buttons __, fields __. You just did — by hand — the exact inventory a test generator does first when it learns a site.
You know what a page is made of and how tests find things in it. Next: your first real test, line by line.