AI Playwright Failure Investigation Agent: From Red Build to Root-Cause Diagnosis
Automating root-cause analysis by correlating Playwright traces, NestJS terminal logs, and PostgreSQL query state.
01. The Problem
02. The Concrete Engineering Scenario
A nightly Playwright transfer test fails intermittently on CI with 'Error: Timed out waiting for transfer status COMPLETED'. Is it a frontend polling bug, a BullMQ queue stall, or a database dead-lock?
Acts as a Forensic Debugging agent that correlates timestamped Playwright network traces, backend application logs, and database transaction queries to pinpoint the exact failure mechanism.
03. Context & Inputs Provided to Agent
- •Playwright Trace archive (network requests, console errors, DOM snapshots).
- •NestJS application container logs during the test window.
- •PostgreSQL query log showing transaction locks and status updates.
- •Redis BullMQ job event stream.
04. Agent Reasoning & Planning Steps
Playwright Interaction
Extracts action metadata from Playwright's trace.playwright.dev artifact format, identifying the exact assertion that timed out.
Evidence Collection
Generates an aggregated timeline showing: T+0ms UI Click -> T+120ms API 201 -> T+150ms BullMQ Enqueue -> T+2100ms Worker Error -> T+5000ms UI Timeout.
05. Concrete Code Excerpt
Correlated Timeline Report Output=== AUTOMATED FORENSIC TIMELINE ===
[12:04:12.102] [BROWSER] User clicks "Confirm Transfer" (btn_transfer_submit)
[12:04:12.215] [BACKEND] POST /api/v1/transfers returned HTTP 201 (TxID: 88f2a)
[12:04:12.228] [DATABASE] INSERT INTO transactions status='PENDING' (Commit OK)
[12:04:12.240] [BULLMQ] Job 'transfer-88f2a' enqueued to transfersQueue
[12:04:14.350] [WORKER] FATAL: Partner banking simulation timed out
[12:04:14.355] [DEFECT] TransfersProcessor caught error but omitted wallet refund (WP-QA-001)
[12:04:22.215] [BROWSER] Assertion timeout: expected status 'COMPLETED', received 'FAILED'Failure & Edge Case Handling
Differentiates between test infrastructure issues (e.g., container ran out of memory) and genuine product defects (e.g., WP-QA-001 refund gap).
Measurable Result
Pinpoints the root cause in 8 seconds, identifying that TransfersProcessor failed silently on simulated network dropouts, drafting a complete bug report for Jira.
Human Review & Approval Gate
Staff SDET validates the finding, confirms the reproduction steps, and links it directly to the known-defect regression suite.
Key Engineering Lessons Learned
Correlating browser traces with server-side logs is the only way to debug asynchronous distributed workflows.
Attaching transaction IDs and correlation IDs to Playwright test metadata makes automated forensic analysis possible.
Clear defect classifications (Bug vs Flake vs Infrastructure) save hundreds of hours of developer friction.