browser - new context - tracing - support for additional arguments provided by playwright
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.
I think now library uses those as defaults, but your idea is nice enhancement.
@allcontributors please add @keef78 for ideas
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 effort of adding that to tracing is HUGE! We would have to add more arguments to
New Contextonly 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
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?
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