Playwright's Trace Viewer is a powerful tool that allows you to profile your tests. It provides a detailed view of each action, including the state of the page before and after the action. You can inspect the log, source, and network during each step of the test.
First, you need to run your tests. Use the command npx playwright show-report
to do this.
npx playwright show-report
After running your tests, an HTML report will open in your browser. You'll see a trace icon next to the test name file name. Click on this icon to open the Trace Viewer for that specific test.
Alternatively, you can open the detailed view of a specific test, scroll down to the 'Traces' tab, and click on the trace screenshot to view it.
Inside the Trace Viewer, you'll see all actions performed by Playwright along with their respective timings. This information is invaluable when you're trying to identify bottlenecks or slow running tests.
Remember, the Trace Viewer creates a DOM snapshot, so you can fully interact with it, open devtools, and more.
Happy testing with Playwright! For more tips and tricks, check out our blog post on Mastering Playwright Test Automation.
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].