When I have code like this, the text passed to the step function shows up in the Playwright trace viewer:
await test.step("Navigate to the blog home page and confirm it is loaded.", async () => {
// etc.
});
I want to have other logged information likewise show up in the traceviewer, just not steps. Maybe something like this:
await test.step("Navigate to the blog home page and confirm it is loaded.", async () => {
test.log.info("some piece of information I want you to see in the trace viewer.");
});
I cannot see anywhere in the Playwright documentation that explains how to do this.
You're probably looking for attachments, they're parts of Trace Viewer.
test("Example", async ({ page }) => {
await test.step("1", async () => {
test.info().attach("Account", { body: JSON.stringify({ user: "admin" }), contentType: "application/json" });
});
});

You may simply have nested test.step statements with calculated values to view inline:
await test.step("First Level-> "+ `${1*1}`, async () => {
await test.step("Second Level-> " + `${2*1}`, async () => {
})
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With