playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Feature]: Ability to extend the trace information

Open taras opened this issue 1 year ago • 9 comments
trafficstars

🚀 Feature Request

If we don't use locators, we'll lose trace information about the elements we're interacting with in the test. Is there a way for us to write to the trace without using locators?

Example

We want to be able to call trace API from the browser or node to add information that locators would otherwise provide.

Motivation

image

https://frontside.com/interactors

I'm part of the team that maintains Frontside Interactors. We're considering creating an integration with Playwright. We tried using async locators, but Interactors's API design doesn't align well with Locators.

taras avatar Apr 30 '24 18:04 taras

@taras You can use test.step() to add steps that would be visible in the trace viewer. However, most of Playwright APIs show in the trace. What do you use under the hood that's missing in the trace viewer?

dgozman avatar Apr 30 '24 19:04 dgozman

It would be nice to be able to write arbitrary data to the trace.

uchagani avatar May 01 '24 01:05 uchagani

Locators in Trace

@dgozman Since we're not using locators, I assume we won't get the traces I highlighted in the image. We want to add these from the node or the browser for interactor interactions.

taras avatar May 01 '24 14:05 taras

@taras Most of Playwright APIs show in the trace, not only locators. What APIs do you use that's missing in the trace viewer?

dgozman avatar May 01 '24 15:05 dgozman

We're building a custom testing harness that uses the Playwright library to start up the browser. We have a custom test runner. Our traces would only show HTTP requests because we don't currently use the test function or locators. We want to use the trace functionality without relying on Playwright's test runner.

taras avatar May 01 '24 15:05 taras

@taras I see, so you basically use Playwright to launch the browser. In this case, there is indeed not much to see in the trace. I will keep this issue open, but the usecase seems to be low priority for Playwright. It looks like it would be easier for you to record your own trace and show it in whatever UI you would like, because there is pretty much nothing from Playwright that could show up in the trace.

dgozman avatar May 01 '24 15:05 dgozman

Thank you very much for considering my request. I would like to clarify that we have two separate use cases.

The primary use case that prompted this request is supporting Playwright to Interactors. This would make it possible for users of Interactors to use the Playwright runner with interactors for their component library. In this case, they'd be using everything except locators.

The second use case is for BigTest, where we're considering replacing WebDriver with Playwright. In the case of BigTest, we have our own declarative test syntax and it's own test runner.

The Interactors use case is a much higher priority for us. Can you give some pointers on how we can send trace information to Playwright, even via some unofficial APIs? I would appreciate it.

Thank you for your time, Taras

taras avatar May 01 '24 22:05 taras

In this case, they'd be using everything except locators.

I think the usual Playwright trace would be almost there. I guess you are using something else instead of locators, probably some kind of page.evaluate() or similar? That should show up in the trace anyway, albeit under the actual API name, not under your wrapper name. I didn't understand whether you use Playwright's test runner in this case, but if you do you can wrap it all with test.step().

Can you give some pointers on how we can send trace information to Playwright, even via some unofficial APIs? I would appreciate it.

Unfortunately, there is no way to achieve this today.

dgozman avatar May 01 '24 23:05 dgozman

I guess you are using something else instead of locators, probably some kind of page.evaluate() or similar?

The design of Intractors is very similar to Playwright locators. They're both convergent and perform chained DOM look-up in one tick of the event loop. You might find this blog post interesting https://frontside.com/blog/2020-07-16-the-lesson-of-bigtest-interactors/

We only use page.evaluate to send the agent what Interactor to call and arguments to that interactor. Actual lookup and interaction happen in the browser context. So it sounds like we should expect to see page.evaluate and arguments in the trace?

I didn't understand whether you use Playwright's test runner in this case, but if you do you can wrap it all with test.step().

In this case, the users would be using Playwright test runner.

taras avatar May 01 '24 23:05 taras

Why was this issue closed?

Thank you for your involvement. This issue was closed due to limited engagement (upvotes/activity), lack of recent activity, and insufficient actionability. To maintain a manageable database, we prioritize issues based on these factors.

If you disagree with this closure, please open a new issue and reference this one. More support or clarity on its necessity may prompt a review. Your understanding and cooperation are appreciated.

pavelfeldman avatar Aug 16 '24 00:08 pavelfeldman