Detailed Log Analysis | Bondar Academy
Course: Playwright API Testing with TypeScript
Module: Test Management
Instructor: Artem Bondar
Lesson Summary
In this lesson, we explore how to obtain detailed information about test case execution for better debugging and analysis in Playwright. Understanding the Need for Detailed Logs While the framework can attach request and response details to reports, there are instances when this information is insufficient. For example, if a test fails or an API request does not go through, additional details may be necessary to identify issues such as: Missing headers Unexpected response data Using Playwright's Trace Feature Playwright offers a feature called Trace that collects comprehensive information about networking interactions. To enable Trace: Open playwright-config.ts . In the use block, add the Trace property. Set Trace to on or use the retain on failure option to save Trace only when tests fail. Analyzing Trace Data After running a test that fails, you can access the Trace data in the playwright-report folder. The Trace view includes: Network Tab: Displays all API requests made during the test. Request Details: Includes URL, method, status code, headers, and authorization tokens. Response Headers: Useful for understanding the context of subsequent API requests. Response Body: Provides the JSON body returned from the API. Reproducing Requests You can copy request details to reproduce the API call using options like copy as CURL or copy as Playwright . This feature allows you to generate the exact code executed during the test: const response = await page.request.get('URL', { headers: { ... } }); These tools enhance your ability to debug API tests effectively. For further assistance, refer to the next lesson.