Three ways to save a page, tested#
We built a fixture page in Chromium 1243 (Playwright 1.63) with an input whose value attribute was initial, typed typed text into it, ticked a checkbox, chose a second option in a select, and attached an open shadow root containing a bold word. Then we saved the page three ways.
| Method | Typed input text | Checkbox ticked, option selected | Open shadow root content |
|---|---|---|---|
document.documentElement.outerHTML, or Copy outerHTML in the Elements panel | Missing: shows value="initial" | Missing | Missing |
MHTML snapshot from the Chrome DevTools Protocol's Page.captureSnapshot, the same single-file format as Chrome's Save page as… | Missing | Missing | Missing |
| Playwright trace DOM snapshot | Present | Present | Present |
The reason is the difference between attributes and properties. Typing changes an input's value property; the value attribute stays as the HTML set it, and serialization writes attributes. A shadow root is not part of the element's children, so outerHTML does not include it. MDN: Element.outerHTML · Chrome DevTools Protocol: Page.captureSnapshot
Save the part of the DOM that matters#
For most reports, the maintainer needs one element and its state, not the whole page.
In the Elements panel, select the element and use Copy > Copy outerHTML for its markup.
In the Console,
$0is the selected element. Read the properties that serialization drops:({ value: $0.value, checked: $0.checked, disabled: $0.disabled, ariaExpanded: $0.getAttribute('aria-expanded'), shadow: $0.shadowRoot?.innerHTML })For an element inside a shadow root,
getHTMLwithserializableShadowRootsor an explicitshadowRootslist includes it. In our fixture,document.body.getHTML({ shadowRoots: [host.shadowRoot] })returned the shadow root's content. MDN:Element.getHTML()Add the computed style that decides a visual bug, such as
getComputedStyle($0).display, rather than the whole stylesheet.
When a whole-page save is right#
Save the whole page when the bug is in structure across the page, such as duplicated IDs, a missing landmark or an element outside the container it should be in. An MHTML file keeps the styles and images, so the maintainer can open it and look. Note in the report that form values and shadow DOM are not in it.
When you need the page state at each step, a Playwright trace records DOM snapshots with input values and is the better format.
Worked example: a coupon field that looked filled#
This example is fictional. A tester reports that applying a coupon says "Enter a code" although the field shows WINTER10. They attach the field's markup from Copy outerHTML: <input name="coupon" value="">.
The empty value attribute does not mean the field was empty, because typing never changes the attribute. The developer asks for the property instead. In the console, $0.value returns "WINTER10 ", with a trailing space from a pasted code, and the server's validation rejected it as malformed before the "Enter a code" fallback message. The outerHTML could not have shown it; the property did. Pasted text that fails covers the clipboard side.
Questions#
Does a Playwright trace record every form state?
In our fixture it recorded typed text, the checkbox and the selected option, stored as extra attributes on each element in the snapshot. It records the page Playwright drove, so it does not help with a bug in someone's everyday browser profile.
Can I send the DOM of a page behind a login?
The DOM contains the page's text, which may include personal data. Copy the element you need, or reproduce with a test account.
Is a DOM save enough to reproduce the bug?
Rarely. It shows the result, not the steps or the data that produced it. Pair it with the steps and the state, as the replay guide describes.
Return to reproducing what someone else saw for the other layers a replay needs.