Challenge - 5 Problems
Raw XML Body Testing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Postman test script?
You send a POST request with raw XML body:
In the Tests tab, you run this script:
What will be the test result?
<note> <to>Alice</to> <from>Bob</from> <message>Hello</message> </note>
In the Tests tab, you run this script:
const xml = pm.request.body.raw;
pm.test('Contains <to> tag', () => {
pm.expect(xml).to.include('<to>Alice</to>');
});What will be the test result?
Postman
const xml = pm.request.body.raw; pm.test('Contains <to> tag', () => { pm.expect(xml).to.include('<to>Alice</to>'); });
Attempts:
2 left
💡 Hint
pm.request.body.raw contains the raw request body as a string.
✗ Incorrect
The raw body string includes the exact substring 'Alice ', so the assertion pm.expect(xml).to.include(...) passes.
❓ assertion
intermediate2:00remaining
Which assertion correctly verifies the raw XML body contains the tag with 'Hello'?
You want to check that the raw XML body sent in a POST request contains the tag <message>Hello</message>.
Which Postman test assertion is correct?
Which Postman test assertion is correct?
Attempts:
2 left
💡 Hint
pm.request.body.raw holds the raw request body as a string.
✗ Incorrect
Option D correctly checks if the raw request body string includes the exact substring 'Hello '. Option D checks response, not request. Option D requires exact match, which is unlikely. Option D uses a wrong property 'body.text'.
🔧 Debug
advanced2:00remaining
Why does this Postman test fail with 'TypeError: Cannot read property "raw" of undefined'?
You wrote this test script:
But when you run it, you get:
What is the most likely cause?
const xml = pm.request.body.raw;
pm.test('Check XML', () => {
pm.expect(xml).to.include('<to>Alice</to>');
});But when you run it, you get:
TypeError: Cannot read property "raw" of undefined
What is the most likely cause?
Postman
const xml = pm.request.body.raw; pm.test('Check XML', () => { pm.expect(xml).to.include('<to>Alice</to>'); });
Attempts:
2 left
💡 Hint
Check if the request body is configured in the request.
✗ Incorrect
If the request body is not set or is empty, pm.request.body is undefined, causing the error when accessing .raw.
🧠 Conceptual
advanced2:00remaining
What is the best way to validate the structure of a raw XML body in Postman tests?
You want to verify that the raw XML body sent in a POST request has a specific structure, for example, it contains a <note> root with <to> and <from> child tags.
Which approach is best in Postman test scripts?
Which approach is best in Postman test scripts?
Attempts:
2 left
💡 Hint
Postman test scripts can use JavaScript libraries to parse XML.
✗ Incorrect
Parsing XML with a DOM parser allows precise validation of structure and content, better than fragile string includes or regex.
❓ framework
expert3:00remaining
How to automate testing of raw XML request bodies in a CI pipeline using Postman/Newman?
You have Postman collections with requests sending raw XML bodies. You want to run automated tests in a CI pipeline using Newman.
Which practice ensures reliable validation of raw XML bodies in this setup?
Which practice ensures reliable validation of raw XML bodies in this setup?
Attempts:
2 left
💡 Hint
Automated tests should validate XML content programmatically for reliability.
✗ Incorrect
Parsing XML in test scripts and asserting structure/content is the most reliable way to validate raw XML bodies in automated CI runs with Newman.