To profile your tests in Playwright, you can utilize the Trace Viewer. This tool lets you view traces of your test, inspect the log, source, and network during each step of the test. It creates a DOM snapshot for full interaction, including opening devtools.
First, run your tests with the following command:
npx playwright show-report
This will open an HTML report in your browser. Look for the trace icon next to the test name file name and click it to open that specific trace.
You can also open a 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 for a particular test case, you'll see all actions performed by Playwright along with their respective timings. This is useful for identifying bottlenecks or slow running tests.
Playwright also supports generating traces programmatically via its API. This allows easy integration into existing workflows without requiring any additional setup or configuration changes.
For more insights on how to detect and handle flaky tests in Playwright, check out this blog post.
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@example.com.