You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Tanner Larson (@TannerLarson), I looked through the existing pytest-playwright tracing flow and the corresponding Playwright trace-viewer support. I'd like to take this as a focused contribution and look at how attachments can be exposed through the pytest integration while keeping the existing tracing behavior unchanged.
I’ll first verify the current fixture/lifecycle and the underlying trace attachment support, then I can propose the smallest implementation and test scope. Please let me know if you'd prefer any particular API shape.
Hi Tanner Larson (@TannerLarson), I dug into the tracing path and found an important limitation before starting implementation.
testInfo.attach() in Node is implemented by the @playwright/test runner itself: it maintains a separate test-trace stream and merges that with the browser trace when the test finishes. The shared Playwright tracing API used by Python doesn't currently expose an equivalent attachment operation.
I also checked playwright-pytest's ArtifactsRecorder: it only starts/stops the browser trace and manages the resulting trace.zip; it has no supported way to inject attachment entries into the trace.
So I don't think this can be implemented cleanly in playwright-pytest alone without depending on Playwright internals. It looks like some upstream support would be needed first. Would you prefer that I track this as an upstream Playwright/Python capability and then revisit the pytest integration once that exists?
Thanks for the investigation, ANUPAM KUMAR (@anupamkr1708). In Node, attachments come from the test runner's own trace stream, which isn't exposed through the Python tracing API (playwright 1.63's Tracing has start/stop/chunks/groups/HAR, no attach), so this can't be done cleanly in pytest-playwright today. Since the original need has gone away, I'm closing this. If more people need it we can revisit it together with a Python-side API; the report attachments from #121 (report.user_properties, pytest-html) cover the non-trace-viewer part.
Activity
anupamkr1708 commentedon Aug 25, 2026
Hi Tanner Larson (@TannerLarson), I looked through the existing pytest-playwright tracing flow and the corresponding Playwright trace-viewer support. I'd like to take this as a focused contribution and look at how attachments can be exposed through the pytest integration while keeping the existing tracing behavior unchanged.
I’ll first verify the current fixture/lifecycle and the underlying trace attachment support, then I can propose the smallest implementation and test scope. Please let me know if you'd prefer any particular API shape.
anupamkr1708 commentedon Aug 26, 2026
Hi Tanner Larson (@TannerLarson), I dug into the tracing path and found an important limitation before starting implementation.
testInfo.attach() in Node is implemented by the @playwright/test runner itself: it maintains a separate test-trace stream and merges that with the browser trace when the test finishes. The shared Playwright tracing API used by Python doesn't currently expose an equivalent attachment operation.
I also checked playwright-pytest's ArtifactsRecorder: it only starts/stops the browser trace and manages the resulting trace.zip; it has no supported way to inject attachment entries into the trace.
So I don't think this can be implemented cleanly in playwright-pytest alone without depending on Playwright internals. It looks like some upstream support would be needed first. Would you prefer that I track this as an upstream Playwright/Python capability and then revisit the pytest integration once that exists?
TannerLarson commentedon Aug 31, 2026
Yeah, that would be fine. Full transparency, I've since mostly moved to Node.js directly, so I'm not as keen on this feature any more
pavelfeldman commentedon Oct 8, 2026
Thanks for the investigation, ANUPAM KUMAR (@anupamkr1708). In Node, attachments come from the test runner's own trace stream, which isn't exposed through the Python tracing API (playwright 1.63's
Tracinghas start/stop/chunks/groups/HAR, no attach), so this can't be done cleanly in pytest-playwright today. Since the original need has gone away, I'm closing this. If more people need it we can revisit it together with a Python-side API; the report attachments from #121 (report.user_properties, pytest-html) cover the non-trace-viewer part.