Jump to content
We've recently updated our Privacy Statement, available here ×
  • If else tests - based on xml response has certain text/string in postman | pm.response.text().has


    Hi, 

    Below piece of code verifies if the xml response has Text1 in it then performs Text1 tests else performs Text2 and Text3 tests respectively. 

     1 2 3 4 5 6 7 8 9101112131415161718192021
    if( pm.response.text().has("Text1")){		console.log("Received : body contains Text1");		pm.test("Body contains Text1",() => {  		pm.expect(pm.response.text()).to.include("Text1");	});	}else{		console.log(" Not Received : Text1 so verifying for Text2 and Text3");	pm.test("Body contains Text2",() => {  		pm.expect(pm.response.text()).to.include("Text2");	});	pm.test("Body contains Text2",() => {  		pm.expect(pm.response.text()).to.include("Text2");	});	}



    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...