Har file analysis and context management

Since browser/playwright has built-in feature to record Har files, has anyone tried to integrate those into into test workflows ?

Ain’t an issue to do this in my keyword teardown and im mainly interested on what sort of things you end up bringing back to the robot framework side and how ?

Also, i’d be interested on hearing your thoughts on playrights Context management in situtation where you might have single testcase but you feed it testdata with [template] ?

3 Likes

I have, well sort of, I tried outputting the har files for use externally for generating a requests library test.

The problem i encountered was there was no way to identify which har entries belonged to which keyword unless i saved the har file and then started a new har file after every keyword step in my test case so that was quite clumsy.

So I’d like to see some additional capability to make it easier to identify in the har file which part of the browser library test case a har entry was related to.

Dave.

I create a new context per test case so essentially i did not have issue with “what har file belongs to what case” and name of the har is in simple terms “suitename.testcase.har”. However, since i do have bunch of templated tests and templated tests are considered a single testcase - having a single context for single testcase caused some other issues (state remains the same between each iteration and what not) so i ended up creating context for each iteration and added the unique part of the test data into har filename… Just to avoid overwriting the same har on each iteration of the templated testcase…

Seems to work somewhat decently… Essentially i have main suite with testcases where each of those tests has [Template] that poinst to actual testcase template keyword. Then on each actual test template (keyword) i have [Setup] that generates that unique har file (and new context), and [Teardown] that then processes the har file and appends WARNING’s for each request that didn’t get a valid http response (200, 302 and what not)…

This way at least i get the warnings to the log without external tooling and they are associated with the correct testcase…


I like the idea about creating possible requests tests. However, in my case everything pretty much everything is done on server side by next.js there’s really nothing interesting except possible missing assets…

1 Like

I’ll have to get back to this at some stage, but the idea was to convert a browser library test case to requests library for performance testing (RFSwarm obviously :wink: ) as you can run many more requests library robots than browser library robots on the same hardware.

So because of this identifying the keyword that generated the content in the har is important as I ideally want to make sure the requests calls the same as they would have been in browser library for the same keyword name.

Now that the V3 listener has start_keyword and end_keyword, that might be a better way to approach it, hmm :thinking: will have to investigate that.

Dave.