robotframework-browser icon indicating copy to clipboard operation
robotframework-browser copied to clipboard

browser - new context - tracing - support for additional arguments provided by playwright

Open keef78 opened this issue 11 months ago • 6 comments

According to Playwright documentation https://playwright.dev/docs/api/class-tracing it should be possible when using "tracing" use additional optional arguments like :

screenshots [boolean] Whether to capture screenshots during tracing. Screenshots are used to build a timeline preview.

snapshots [boolean] If this option is true tracing will capture DOM snapshot on every action record network activity

sources [boolean] Whether to include source files for trace actions.

It would be great to implement also to Browser Library.

keef78 avatar Jan 23 '25 19:01 keef78

I think now library uses those as defaults, but your idea is nice enhancement.

@allcontributors please add @keef78 for ideas

aaltat avatar Jan 24 '25 11:01 aaltat

@aaltat

I've put up a pull request to add @keef78! :tada:

allcontributors[bot] avatar Jan 24 '25 11:01 allcontributors[bot]

The effort of adding that to tracing is HUGE! We would have to add more arguments to New Context only to disable the tracing screenshots? I mean maybe that makes sense, but i doubt it.

Because as @aaltat already wrote, screenshots and snapshots are active in Browser lib. and adding the Sources to the trace file, does imho not make sense in case of RF.

However, with a simple js plugin it is possible to start your own trace with all your configuration you want.

exports.__esModule = true;
exports.startTracing = startTracing
exports.stopTracing = stopTracing

async function startTracing(context) {
    await context.tracing.start({screenshots: false, snapshots: false});
}

async function stopTracing(tracefile, context, logger) {
    logger(`Tracing file: ${tracefile}`);
    await context.tracing.stop({ path: tracefile });
}
*** Settings ***
Library    Browser    jsextension=${CURDIR}/js_keywords.js


*** Test Cases ***
Test
    New Browser
    New Context
    Start Tracing
    Do Stuff
    [Teardown]    Stop Tracing     ${CURDIR}/mytracefile.zip

Therefore my current proposal is to close that issue. I also do not see much benefit as of now, to disable these screenshots and snapshots. Those are extremely helpful! @aaltat closable?

Snooz82 avatar Oct 05 '25 20:10 Snooz82

The effort of adding that to tracing is HUGE! We would have to add more arguments to New Context only to disable the tracing screenshots? I mean maybe that makes sense, but i doubt it.

Because as @aaltat already wrote, screenshots and snapshots are active in Browser lib. and adding the Sources to the trace file, does imho not make sense in case of RF.

However, with a simple js plugin it is possible to start your own trace with all your configuration you want.

exports.__esModule = true; exports.startTracing = startTracing exports.stopTracing = stopTracing

async function startTracing(context) { await context.tracing.start({screenshots: false, snapshots: false}); }

async function stopTracing(tracefile, context, logger) { logger(Tracing file: ${tracefile}); await context.tracing.stop({ path: tracefile }); } *** Settings *** Library Browser jsextension=${CURDIR}/js_keywords.js

*** Test Cases *** Test New Browser New Context Start Tracing Do Stuff [Teardown] Stop Tracing ${CURDIR}/mytracefile.zip Therefore my current proposal is to close that issue. I also do not see much benefit as of now, to disable these screenshots and snapshots. Those are extremely helpful! @aaltat closable?

the idea came from the situation where we have huge scenarios and logging traces is bit painfull due to the the size of the trace file adn looking ways how to create a smallest trace file as possible (sure this can be managed aftewards as well by post run actions) , but for those cases we may not me interested in time line screenshots , because console log and network log from traces together with screenshot on failure is sufficent for debugging the error

keef78 avatar Oct 06 '25 07:10 keef78

So @keef78 ,

would the JS Plugin be enough for you? i understand the need in a specific case, but due to the big effort i would not invest much time into that.

What do you think?

Snooz82 avatar Oct 06 '25 09:10 Snooz82

So @keef78 ,

would the JS Plugin be enough for you? i understand the need in a specific case, but due to the big effort i would not invest much time into that.

What do you think?

sure, thank you, in the case of need, we can use tracing as suggested .)

Filip

keef78 avatar Oct 06 '25 10:10 keef78