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 9 10 11 12 13 14 15 16 17 18 19 20 21 | 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"); }); } |
No comments:
Post a Comment