To record a trace during development, you can use the --trace
flag. Run your tests with the following command:
npx playwright test --trace on
This command will record traces for each test. You can then open the HTML report and click on the trace icon to view the trace.
You can also record traces on continuous integration (CI) on the first retry of a failed test. To do this, set the trace: 'on-first-retry'
option in your test configuration file (playwright.config.ts
). This will produce a trace.zip
file for each retried test.
module.exports = {
trace: 'on-first-retry'
};
To view the traces, you can use Playwright's Trace Viewer tool. This tool provides details about each action in your tests, such as the action called, its time and duration, parameters, return value, log output, console logs or errors, network requests made during the action, and source code for your entire test.
Playwright comes with a range of tools that can help you write tests effectively. These tools include features like stepping through tests while viewing actionability logs and editing locators live to see them highlighted in the browser window.
If you're not using Playwright as a Test Runner, you can use the browserContext.tracing
API instead.
If you still have questions, please ask a question and I will try to answer it.
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].