在郵遞員的測試結果中打印響應正文元素


0

我需要在郵遞員的"測試結果"部分中,從API的響應正文中打印一個特定的Response元素。

1

Assuming that you want to print a data from the response value

var jsonData = pm.response.json();

var testmessage=jsonData._data[0].UserName //Dev_demo_82
pm.test(testmessage, function () {
   //testscript

});

Response value of Property UserName will be stored in variable testmessage now your test name will be displayed as shown in image below

enter image description here


1

Mohamed's step will allow you to do what you wanted, but if you are trying to debug something then postman already have the postman console for this purpose.

so just use console.log() in the prerequisite or test script session and open view>show postman console in the postman menu bar.

Now run the request and you can see that the value is printed in the console.

Opening:

enter image description here

Viewing:

enter image description here

Note: if you click on the request it will show all details like the request header, body, response etc

in newman htmlextra report you can get these details in the report using the --reporter-htmlextra-logs flag