Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Ability to add custom annotations to trace files #28206

Closed
minhhai2209 opened this issue Nov 16, 2023 · 5 comments
Closed

[Feature] Ability to add custom annotations to trace files #28206

minhhai2209 opened this issue Nov 16, 2023 · 5 comments

Comments

@minhhai2209
Copy link

I would like to propose a feature for the Playwright tracing facility that allows users to add custom annotations (free text) to trace files. Currently, Playwright's tracing capabilities automatically record actions like page.navigate, page.click, etc. While this is incredibly useful, the ability to insert custom annotations would enhance the trace's usefulness and readability, especially for complex scenarios.

Use Case and Benefits

In many testing and debugging scenarios, it's beneficial to have context-specific information that explains why certain actions are taken or to mark important checkpoints in the trace. Custom annotations can serve as explanatory notes or markers within the trace file, making it easier to understand the flow, especially when sharing these traces with other team members.

For instance, a test might involve a series of steps with conditional logic, and being able to annotate the trace with information like "Starting Section A tests" or "Conditional logic X triggered" would be valuable.

Suggested Implementation

The implementation could be a simple API method, such as page.annotateTrace("Your annotation here"), which inserts the given text into the trace at the point where the method is called. These annotations should be visible when viewing the trace file in a compatible viewer.

Example:

page.annotateTrace("Starting login test sequence");
page.fill("input[name='username']", "testuser");
page.fill("input[name='password']", "password");
page.click("text='Log in'");
page.annotateTrace("Login test sequence completed");

In this example, the annotations provide clear markers that denote the beginning and end of a login test sequence, which would be reflected in the trace viewer.

@mxschmitt
Copy link
Member

Have you tried custom annotations inside your test or wrapping your logic steps inside test.step? I think the latter would fit very well for your use-case.

@minhhai2209
Copy link
Author

Thank you @mxschmitt. Unfortunately, we are not using the Playwright Test framework, and changing the test framework is not an option for me currently. But this is still a great hint for me - I'll take a look at the Playwright Test source code. Do you have any extra suggestions?

@mxschmitt
Copy link
Member

Closing as per above then. We recommend annotations and then they get surfaced in HTML as well. We strongly recommend Playwright's test-runner, since you will miss features like HTML Report, retries, VS Code extension, UI Mode etc.

@mxschmitt mxschmitt closed this as not planned Won't fix, can't repro, duplicate, stale Nov 20, 2023
@coty
Copy link

coty commented Nov 20, 2023

Have you tried custom annotations inside your test or wrapping your logic steps inside test.step? I think the latter would fit very well for your use-case.

@mxschmitt We're trying to do this from a Java test. Any thoughts on how non-JS frameworks should work with this?

@mxschmitt
Copy link
Member

Sounds like microsoft/playwright-java#1416, there are no plans as of today to add it but feel free to comment there / upvote it there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants