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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Ability to extend the trace information #30610

Open
taras opened this issue Apr 30, 2024 · 9 comments
Open

[Feature]: Ability to extend the trace information #30610

taras opened this issue Apr 30, 2024 · 9 comments

Comments

@taras
Copy link

taras commented Apr 30, 2024

馃殌 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.

@dgozman
Copy link
Contributor

dgozman commented Apr 30, 2024

@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?

@uchagani
Copy link
Contributor

uchagani commented May 1, 2024

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

@taras
Copy link
Author

taras commented May 1, 2024

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.

@dgozman
Copy link
Contributor

dgozman commented May 1, 2024

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

@taras
Copy link
Author

taras commented May 1, 2024

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.

@dgozman
Copy link
Contributor

dgozman commented May 1, 2024

@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.

@taras
Copy link
Author

taras commented May 1, 2024

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

@dgozman
Copy link
Contributor

dgozman commented May 1, 2024

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.

@taras
Copy link
Author

taras commented May 1, 2024

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.

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

No branches or pull requests

3 participants