I am a learner in Postman and trying to read through a CSV file. I am trying to identify from my CSV file the Place Name against the Combination of Country Name and Postal Code.
My CSV looks like this:
Country , Postal Code , Place Name
us , 90210 , Beverly Hills
us , 12345 , Schenectady
ca , B2R , Waverley
So if the Country is us and the Postal Code is 90210, Place Name should be Beverly Hills
if the Country is us and the Postal Code is 12345, Place Name should be Schenectady
if the Country is ca and the Postal Code is B2R, Place Name should be Waverley
I have tried so far as included, but somehow it doesnt identify the Place Name correctly and even if I change the Code to something else, lets say 90210111 instead of 90210, I dont get an error at all, even though it doesnt qualify the criteria.
pm.test("Test 2 - Verify in Response - "Place Name" for each input "Country" and "Postal Code"", () => {
let jsonData = pm.response.json();
console.log(jsonData);
if ((Country === "us") && (Postal_code === '90210'))
{
console.log("COUNTRY IS " + Country);
console.log("Postal_code IS " + Postal_code);
console.log("Place Name IS " + Place_name);
pm.expect(Place_name).to.be.eql('Beverly Hills121212');
console.log("US 90210 TRUEEEEEE");
}
if (((Country === "us") && (Postal_code === '12345')))
{
console.log("COUNTRY IS " + Country);
console.log("Postal_code IS " + Postal_code);
console.log("Place Name IS " + Place_name);
pm.expect(Place_name).to.be.eql('Schenectady1212');
console.log("US 12345 TRUEEEEEE");
}
if (((Country === "ca") && (Postal_code === 'B2R')))
{
console.log("COUNTRY IS " + Country);
console.log("Postal_code IS " + Postal_code);
console.log("Place Name IS " + Place_name);
pm.expect(Place_name === 'Waverley1212').to.be.true;
console.log("CA B2R TRUEEEEEE");
}
});
1