> For the complete documentation index, see [llms.txt](https://docs.bugbug.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bugbug.io/debugging-tests/dom-snapshot.md).

# DOM Snapshot

BugBug saves the DOM of the page when a test fails. How to turn DOM snapshots on, open one from runs history, how long it's kept, and inspect it in Chrome DevTools.

When a test fails, BugBug automatically captures the full DOM structure of the page at the exact moment of failure. You can then inspect it using browser DevTools — just like inspecting a live page.

***

#### Enabling DOM snapshots

DOM snapshots are **enabled by default**. To change this setting, go to [Project settings](https://docs.bugbug.io/preventing-failed-tests/project-settings.md) and find **Capture DOM on failure**.

<figure><img src="https://3168433179-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MKixgeBPbLvnD0l1eiV%2Fuploads%2F4q7DTAn8bEGAeQXKKIwt%2Fimage.png?alt=media&amp;token=791929ae-55ab-4289-b30e-b1a62c0e413d" alt=""><figcaption></figcaption></figure>

***

#### How to access a DOM snapshot

DOM snapshots are available for test runs with a **Failed** or **Error** status.

1. Go to the [Runs history](https://docs.bugbug.io/debugging-tests/runs-history.md)
2. Click on the failed test run to open its details
3. Click the **Show DOM snapshot** button

![](https://3168433179-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MKixgeBPbLvnD0l1eiV%2Fuploads%2FLfRS6dzYbGubShUXZf2U%2Fimage.png?alt=media\&token=815d4dda-71b2-431b-90e3-0fb1a807c778)

The snapshot opens in a new browser tab, showing the page structure as it was when the test failed.

{% hint style="info" %}
DOM snapshots are kept for **7 days** after the run. After that, the snapshot isn't available anymore.
{% endhint %}

***

#### Inspecting the DOM snapshot

Once the snapshot is open, you can use **Chrome DevTools** to inspect the page just like you would on a live site.

1. Right-click anywhere on the page → **Inspect**, or press `F12`
2. Use the **Elements** panel to browse the HTML structure
3. Check element attributes, classes, and computed styles to understand why a selector may have failed to match

<figure><img src="https://3168433179-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MKixgeBPbLvnD0l1eiV%2Fuploads%2F3mkyD8X6khUyHpG5P3yl%2Fimage.png?alt=media&amp;token=2f35fec8-94c5-43f4-83d2-782619f05623" alt=""><figcaption></figcaption></figure>

***

#### Common debugging scenarios

**Selector not found**

Inspect the element BugBug was trying to interact with. Check if its attributes or structure have changed since the test was recorded. See [tips on fixing selectors](https://docs.bugbug.io/preventing-failed-tests/selectors.md#tips-on-fixing-selectors).

**Assertion failed**

Find the element your assertion targeted and verify its actual content, value, or visibility state at the time of failure.

**Page loaded incorrectly**

Browse the DOM to see if key elements are missing, hidden, or rendered differently than expected.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.bugbug.io/debugging-tests/dom-snapshot.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
