The Browser & DOM
The big question: “The DOM tree, selectors, events — the automation tester’s hunting ground”
JavaScript exists to make web pages come alive: menus that open, forms that complain, feeds that refresh without reloading. All of it works by editing the browser’s live model of the page — the DOM. For you specifically, this phase is the job: an automated test finds elements in this tree, acts on them, and reads the results back out of it. The DOM is your future workplace.
Every web page’s structure is written in HTML — plain text wrapped in tags, like <li class="todo">buy milk</li>. The tag name (li) says what kind of thing this is; anything else inside the angle brackets, like class="todo", is an attribute — extra information about that one element. CSS is a separate language for how things LOOK (colors, spacing, layout) — and it uses the same kind of selectors you’re about to learn, just to say which elements to style instead of which ones to grab in code.
A web page looks like a picture, but to the browser it’s a family tree of elements — the DOM. Every button, heading and input is a node on that tree, and JavaScript can find any node, read it, change it, or listen to it.
Finding nodes is done with selectors — little address patterns like “the button inside the login form.” When a user clicks, an event ripples through the tree, and code can catch it at any level.
Pay extra attention here: this tree is exactly what you’ll automate for a living. A Playwright test is, at heart, “find this element, act on it, check the result.” Testers who write good selectors are worth gold; this phase is where that skill starts.
The language a web page’s structure is written in — plain text wrapped in tags.
A tag like <li> names what kind of thing an element is; an attribute like class="todo" (written inside the tag) adds extra information about it.
body (the visible page), h1–h3 (headings), p (paragraph), ul / li (bulleted list / one item in it), a (link), button, input (a form field), form, div / span (plain boxes for grouping).
A separate language for how things look — colors, spacing, layout. Uses the same kind of selectors you’ll write to find elements.
The Document Object Model — the live family tree the browser builds from HTML. Change the tree and the page changes instantly.
One item in the tree: a button, a paragraph, an image.
A pattern for finding elements, like ".login-form button" — the address system of the page.
A signal that something happened: a click, a keypress, a form submit. Code can listen and react.
Events ripple upward from the element to its ancestors — so a parent can hear its children’s events.
The browser turning the tree into pixels. Elements can exist before they’re visible — the root cause of flaky tests.
- ✓Read an HTML tag and its attributes, and explain what CSS is for
- ✓Sketch the DOM tree for a simple page
- ✓Write a selector to hit any element — first try
- ✓Wire up events and explain how one listener can watch 100 buttons
- ✓Explain why an element can exist but not yet be clickable (flaky-test seed)
✏️ This phase’s interactive lab is still being drawn — it arrives together with the phase’s lessons.
- 7.1The DOM tree
HTML text parsed into a LIVE tree of node objects — your hunting ground.
- 7.2Selecting elements
querySelector + the CSS selector language — THE locator skill of the job.
- 7.3Reading & changing the DOM
textContent vs innerHTML (the XSS rule), classList verbs, create → append → remove.
- 7.4Events
addEventListener, the event object, the big four — what Playwright actions dispatch.
- 7.5Bubbling, delegation & preventDefault
Events travel the tree — one parent listener handles a hundred children.
- 7.6Forms & user input
Values, checkboxes, validation, the submit flow — automation’s daily bread.
- 7.7Storage & timing
localStorage/cookies (test sessions!) and DOMContentLoaded vs load.
- 7.8How the browser renders
Parse → render tree → layout → paint — why “not visible yet” happens.
- 7.9Checkpoint: todo app, inspected
Build it, then target it — your own app as the automation practice range.