Hi,
I would like to code a post script test but I am quite a beginner in postman an java.
Also, I will appreciate some help.
Some time, my request can generate this kind of response :
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/”>
*<SOAP-ENV:Header/>*
*<SOAP-ENV:Body>*
*<SOAP-ENV:Fault>*
*<faultcode>SOAP-ENV:Server</faultcode>*
*<faultstring>Failed to execute program! \[Error during execution: 'xxxxx'\]</faultstring>*
*</SOAP-ENV:Fault>*
*</SOAP-ENV:Body>*
</SOAP-ENV:Envelope>
I have tried to follow some samples written in the Postman documentation but with no success.
Here is below my post-script :
pm.test(“Status code is 200”, function () {
pm.response.to.have.status(200);
});
const xml2js = require(‘xml2js’);
let jsonResponse;
xml2js.parseString(pm.response.text(),{explicitArray: false}, (err, result)=>{
***jsonResponse = result;***
});
console.log(jsonResponse);
pm.test(“Fault string is empty”, function () {
pm.expect(jsonResponse.Envelope.Body.Fault).to.be.empty;
});
The first test is OK. But I don’t know how to test that there ise no Fault or faultstring in the response.
Thank you for your help.