playwright-java
playwright-java copied to clipboard
[Feature]: Trace viewer log type actions
🚀 Feature Request
It can be great to have the possibility to add "log" action to the list of actions on the trace viewer to better following the tests execution and so easy readiness. It can also facilitate debugging.
Example
For example, if we are writing a Junit integration test like that.
myService.createOrder(new order) myService.addOrderLine(myOrder, new line1) myService.addOrderLine(myOrder,new line 2)
myApp.jmsPublishOrder(myOrder)
page.navigate(toPublishedOrder) assertThat(page.locator(myOrderId).isVisible()
myApp.jmsValidateOrder(myOrder)
page.navigate(toValidatedOrder) assertThat(page.locator(myOrderId).isVisible()
myApp.doSomeMoreTimeConsimingActions()
page.navigate(toOrderFinised())
===========>
It can be good to see:
Log Preparing new order 1 Log Send order Page.navidate toPublishedOrder Locator.expect myOrderId Log Validate order 1 Page.navidate toValidatedOrder Locator.expect myOrderId Log do some more time consuming actions page.navigate(toOrderFinised())
Motivation
We are using Playwright for simple gui tests and complexe automatique integration tests. Our complexe tests can have a lot of steps and are used on a system that interact with:
- Real hardware's (robots, sensor etc...),
- Physicals user actions
- External systems that send actions to do to the system
The web application uses a lot of Server Sent Event that update the display of the GUI. The Playwright Traces are saved as proof of tests execution success and so it can be wery useful to be able to better follow the test and to understand which external action influence the gui display and so the Playwright navigations, actions and checks we are doing.
Workaround
Currently we are doing as workaround Page.evaluate("console.log('my log')"). It allows to understand test execution but in the list of actions we have juste Page.evaluate. The detail of the log can be seen in the detail of the evaluate or in the console. As we have a GUI snapshot for Page.evalute, this solution as also the disadvantage of increasing the size of the Trace zip
Related request in python https://github.com/microsoft/playwright-python/issues/1949
Sounds like something similar to test.step
from Node.js version should address the problem by naming related groups of actions.
idea: we could add a TestStep
fixture that allows this?
public void fooTest(TestStep step, Page page) {
step.describe("Prepare new order", () -> {
// some playwright actions
}
}
Although this won't solve any logging any non-playwright actions but I don't think playwright currently allows that anyways. There are other issues similar to this most recently https://github.com/microsoft/playwright/issues/30610.
Step is a good idea to add more context. For my use case, as I'm doing complexe integration tests with multiple "actors", it is important to have the possibility to add "non playwrigth" actions. I'm doing external actions that sents update GUI using SSE.
For example, i can do :
- check Motor power OFF on GUI
- External action, power ON Motor => new SSE with power ON
- check Motor power ON on GUI
if i don't have the information of the external action, it is difficult to understand why I'm doing a check on OFF and just after ON without any apparent change:
- check Motor power OFF on GUI
- check Motor power ON on GUI