# Webwright Output Artifact Structure: Screenshots, Logs, and Trajectory Files Explained

> Understand the Webwright output artifact structure. Learn how screenshots, logs, and trajectory files are organized for every run under your specified output folder.

- Repository: [Microsoft/Webwright](https://github.com/microsoft/Webwright)
- Tags: deep-dive
- Published: 2026-06-25

---

**Webwright stores every run's artifacts in a deterministic directory tree under your specified output folder, including a top-level [`trajectory.json`](https://github.com/microsoft/Webwright/blob/main/trajectory.json) and per-run folders containing generated scripts, execution logs, step metadata, and screenshots.**

The open-source **microsoft/Webwright** project organizes every automation run into a reproducible file structure designed for debugging, self-verification, and external rendering. When you execute a task using the `-o` flag, the framework creates a comprehensive artifact hierarchy that captures the complete execution trajectory. Understanding this output artifact structure is essential for troubleshooting failed runs, analyzing agent behavior, and integrating results into downstream workflows.

## Directory Layout Overview

Webwright creates a root output directory (e.g., `outputs/default`) containing deterministic subdirectories for each execution. The architecture separates global run metadata from per-execution artifacts:

```text
outputs/
└── <output-dir>/                     # e.g., "default"

    ├── trajectory.json                # Full run transcript with token usage

    ├── final_runs/
    │   └── run_<N>/                   # Per-clean run (001, 002, etc.)

    │       ├── final_script.py        # Generated Playwright script

    │       ├── final_script_log.txt   # Line-by-line execution log

    │       ├── steps.jsonl            # Structured step metadata (optional)

    │       └── screenshots/           # PNG captures per critical step

    └── task_showcase/                 # Optional dashboard data

```

This layout ensures that every piece of data needed to reconstruct a run remains isolated within the workspace directory you provide to the CLI.

## Core Artifact Files Explained

### trajectory.json (Run Transcript)

The [`trajectory.json`](https://github.com/microsoft/Webwright/blob/main/trajectory.json) file sits at the root of your output directory and serves as the primary execution record. According to the source code in [`src/webwright/run/cli.py`](https://github.com/microsoft/Webwright/blob/main/src/webwright/run/cli.py) (lines 81-84), this JSON object captures every assistant message, tool call, and token-usage snapshot throughout the agent's lifecycle.

The CLI configures the agent's `output_path` to point directly to this file, ensuring comprehensive logging of the conversation flow and API consumption metrics.

### final_script.py (Generated Playwright Code)

Within each `final_runs/run_<N>/` folder, the [`final_script.py`](https://github.com/microsoft/Webwright/blob/main/final_script.py) contains the actual Playwright Python code generated by the model's planning phase. This executable script represents the deterministic automation logic derived from the natural language task description.

### final_script_log.txt (Execution History)

The [`final_script_log.txt`](https://github.com/microsoft/Webwright/blob/main/final_script_log.txt) provides a plain-text, line-by-line log of every action the generated script performs. As implemented in [`src/webwright/tools/self_reflection.py`](https://github.com/microsoft/Webwright/blob/main/src/webwright/tools/self_reflection.py), this file includes entries such as "step 0 params..." and the final response from the environment.

The self-reflection tool leverages this log through the `_load_action_history_log` method to supply action-history prompts for subsequent reasoning steps.

### steps.jsonl (Structured Step Metadata)

An optional `steps.jsonl` file contains line-delimited JSON entries with per-step metadata. This structured format is consumed by the Task-Showcase renderer, specifically parsed by the `parse_steps_jsonl` function in [`assets/task_showcase/app.py`](https://github.com/microsoft/Webwright/blob/main/assets/task_showcase/app.py), enabling dashboard visualization of execution flows.

### Screenshots Directory

The `screenshots/` subdirectory contains PNG files following the naming pattern `final_execution_<step>_<action>.png`. These images are captured via `page.screenshot()` calls within the environment implementations.

In [`src/webwright/environments/local_browser.py`](https://github.com/microsoft/Webwright/blob/main/src/webwright/environments/local_browser.py), the framework creates this directory using `self._screenshots_dir().mkdir(parents=True, exist_ok=True)`, while [`src/webwright/environments/local_workspace.py`](https://github.com/microsoft/Webwright/blob/main/src/webwright/environments/local_workspace.py) provides the helper method `def _screenshots_dir(self) -> Path:` for workspace-wide screenshot management. The self-reflection tool auto-discovers these images through `_discover_latest_run_screenshots`.

## Optional Task Showcase Artifacts

When utilizing the Task-Showcase overlay (configured via [`task_showcase.yaml`](https://github.com/microsoft/Webwright/blob/main/task_showcase.yaml)), Webwright generates additional artifacts under `task_showcase/tasks/<short_id>/`. As documented in [`assets/task_showcase/README.md`](https://github.com/microsoft/Webwright/blob/main/assets/task_showcase/README.md), this folder contains the minimal [`task.json`](https://github.com/microsoft/Webwright/blob/main/task.json) and [`report.json`](https://github.com/microsoft/Webwright/blob/main/report.json) files required by the Flask dashboard for repeatable task visualization and reporting.

## How to Inspect and Use Artifacts

Execute a run and examine the generated structure using these commands:

```bash

# Run a task with artifact output

python -m webwright.run.cli \
    -c base.yaml -c model_openai.yaml \
    -t "Find the best price for a 2025 MacBook Pro" \
    --task-id macbook_demo \
    -o outputs/default

# Inspect the per-run artifacts

ls -R outputs/default/final_runs/run_001

# Output: final_script.py  final_script_log.txt  steps.jsonl  screenshots/

# Analyze token usage from trajectory

cat outputs/default/trajectory.json | jq '.messages[-1].extra.usage'

# Launch the Task-Showcase dashboard

python assets/task_showcase/app.py \
    --tasks-dir outputs/default/final_runs/run_001/task_showcase/tasks

```

## Summary

- **Webwright's output artifact structure** creates a deterministic hierarchy under your specified `-o` directory, ensuring reproducible runs.
- **The [`trajectory.json`](https://github.com/microsoft/Webwright/blob/main/trajectory.json)** file at the root contains the complete execution transcript and token usage statistics, configured in [`src/webwright/run/cli.py`](https://github.com/microsoft/Webwright/blob/main/src/webwright/run/cli.py).
- **Each run folder** (`final_runs/run_<N>/`) contains the generated Playwright script, execution log, optional structured steps, and screenshot captures.
- **Screenshots** are automatically captured during critical execution points and discovered by the self-reflection tool via [`src/webwright/tools/self_reflection.py`](https://github.com/microsoft/Webwright/blob/main/src/webwright/tools/self_reflection.py).
- **Task-Showcase artifacts** provide dashboard-ready JSON files when the overlay configuration is active.

## Frequently Asked Questions

### Where does Webwright store screenshots?

Screenshots are stored in `final_runs/run_<N>/screenshots/` within your specified output directory. The environment code in [`src/webwright/environments/local_browser.py`](https://github.com/microsoft/Webwright/blob/main/src/webwright/environments/local_browser.py) creates this directory automatically and names files using the pattern `final_execution_<step>_<action>.png`.

### What is the trajectory.json file used for?

The [`trajectory.json`](https://github.com/microsoft/Webwright/blob/main/trajectory.json) file serves as the comprehensive execution record for the entire run. It captures every assistant message, tool invocation, and token-usage snapshot, allowing you to analyze conversation flows and API costs retrospectively.

### How can I view the execution history of a specific run?

Examine the [`final_script_log.txt`](https://github.com/microsoft/Webwright/blob/main/final_script_log.txt) file located in the specific run's directory under `final_runs/run_<N>/`. This plain-text log contains line-by-line records of all script actions and responses, parsed by the self-reflection tool to build action-history contexts.

### Are the output artifacts reproducible across runs?

Yes, the output artifact structure guarantees reproducibility by isolating each clean execution in its own `final_runs/run_<N>/` folder containing the exact generated script, execution logs, and environmental screenshots needed to reconstruct the session.