I am building a custom report for karate execution and for that i need to capture the feature file name, scenario/scenario outline name, scenario desc, request sent and response status and response body. I know we can capture most of the items using karate.info, but is there a way to capture request made and response received ?
Asked
Active
Viewed 1,972 times
1 Answers
2
The response is available in response
and responsebytes
.
And the request is in karate.prevRequest
https://github.com/intuit/karate#karate-prevrequest
I do think you are doing un-necessary work, because you will see this in the HTML reports by default.

Peter Thomas
- 54,465
- 21
- 84
- 248
-
Thanks Peter,, I would like to pick a token from network(devtools) in UI automation, when i login into a site, there is a token in json thats only visible via devtools.. Whats the way to read that data from console/network in karate ? – Gaurav Khurana Mar 10 '21 at 11:39
-
1@Gauravkhurana I don't know, and I would consider this not supported by karate. that said, you should be able to get this using `driver.send()` (which is experimental) - refer: https://github.com/intuit/karate/tree/develop/examples/ui-test#devtools-protocol-tips – Peter Thomas Mar 10 '21 at 11:44
-
https://i.imgur.com/1468g8J.png can you check this, to explain it better... i would like to pick data from the responses in back end which are not visible in UI – Gaurav Khurana Mar 10 '21 at 12:07
-
https://stackoverflow.com/questions/45847035/using-selenium-how-to-get-network-request to be exact here how its being done in Selenium @Peter.. – Gaurav Khurana Mar 10 '21 at 12:10
-
1@Gauravkhurana great ! sounds like you are ready to submit a PR :) - but seriously, I think you have forgotten that karate is able to make GET or POST calls. just do a normal API call and then get the headers, and I think that solves your problem. else as I said, this is not something I consider a priority – Peter Thomas Mar 10 '21 at 13:31
-
i used that and i loved it. But sometimes these internal calls are not allowed via normal API calls.. because the software we are testing is third part.. first it logs and then make a call internally.. For example log into gmail and then when you click on inbox , it makes some call. Do you think it will always be possible.. because that gmail(sign in thing) might not be available.. in case you if you can have the demo for such a site.. that would be helpful – Gaurav Khurana Mar 10 '21 at 14:16
-
1@Gauravkhurana karate can do this, refer: https://twitter.com/KarateDSL/status/1350743622312894466 - if you want anything more than that, please. contribute. code. thank you. – Peter Thomas Mar 10 '21 at 14:18