Quantcast
Channel: Pochampalli IT Labs
Viewing all articles
Browse latest Browse all 261

If else tests - based on xml response has certain text/string in postman | pm.response.text().has

$
0
0

Hi, 

Below piece of code verifies if the xml response has Text1 in it then performs Text1 tests else performs Text2 and Text3tests 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");
});

}



Viewing all articles
Browse latest Browse all 261

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>