Friday, 20 May 2022

Print the environment name on console and based on environment selection write if else condition to execute a particular test in newman/postman

Hi, 

1) Print the selected environment on console
2) if else condition to execute a particular test based on the environment. 
 
console.info(pm.environment.name);
pm.environment.set("currentEnvName",pm.environment.name);
var environementName = pm.environment.get("currentEnvName");
console.log("Environement Name Current Used Is : "+environementName);

if(pm.environment.name=="Server1" || pm.environment.name=="Server2"
	||pm.environment.name=="Server3"||pm.environment.name=="Server4" ){
		postman.setNextRequest(null);
} else
{
	postman.setNextRequest("TestCase123");
}

References:
https://stackoverflow.com/questions/58612238/postman-get-the-environment-name-as-a-variable

No comments:

Post a Comment