playwright-dotnet icon indicating copy to clipboard operation
playwright-dotnet copied to clipboard

[Feature]: TS style test.step trace file grouping

Open infinitejest69 opened this issue 1 year ago • 1 comments

🚀 Feature Request

I would really like to see some way to use the grouping of steps in trace files the node test runner has into c#

so in TS you can specify

  await test.step('Add Folder Model', async () => {
   //Some Actions like clicking and filling
  });

These appear nicely in a trace and improve it readability massively image

in c# we already have tools like specflow or Reqnroll to make these nice English readable test steps. i would like to add to a before step hook the name of the step and after step hook to close the group

Example

At a guess something that you can access from the browser context tracing ?

        [BeforeStep]
        public async Task BeforeStep(ScenarioContext scenarioContext) {
            var browserContext = scenarioContext.ScenarioContainer as IBrowserContext;
            browserContext.Tracing.StartGroup(scenarioContext.StepContext.StepInfo.Text);
            }

        [AfterStep]
        public async Task AfterStep(ScenarioContext scenarioContext) {
            var browserContext = scenarioContext.ScenarioContainer as IBrowserContext;
            browserContext.Tracing.EndGroup(scenarioContext.StepContext.StepInfo.Text);
            }

Motivation

Makes looking through trace files much nicer and easier and readable what the test is doing

infinitejest69 avatar Aug 27 '24 11:08 infinitejest69

Related requests: https://github.com/microsoft/playwright-java/issues/1565 https://github.com/microsoft/playwright-python/issues/1949

hopefully it gets out of the p3-collecting-feeback boneyard 🙏🙏🙏

scott-au avatar Aug 28 '24 19:08 scott-au

This will be available in v1.49.0 soon as part of Contex.Tracing.GroupAsync and Context.Tracing.GroupEndAsync API.

mxschmitt avatar Nov 21 '24 13:11 mxschmitt

This works like a charm, thanks allows me to have nice BDD English steps in my trace files

infinitejest69 avatar Nov 22 '24 13:11 infinitejest69