I am new to postman API testing.
Recently I am using it's collection runner to test request iteration with data file(json).
The weird thing is if I try to access the environment variable that I set before, the console log always shows [object Object]
instead of Object {}
.
Here's my pre-request code on postman:
postman.setEnvironmentVariable("username", data.username);
postman.setEnvironmentVariable("password", data.password);
and the Tests code on postman:
var userData = {
username: environment.username,
password: environment.password
};
postman.setEnvironmentVariable("user", userData);
console.log(environment.user);
for(var key in environment.user){
console.log(key + ": "+ environment.user[key]);
}
Request URL: https://echo.getpostman.com/get?username={{username}}&password={{password}}
data.json:
[{
"username" : "Jon Snow",
"password" : "iloveGot123"
},{
"username" : "Akali",
"password" : "iWillKickyalla55"
},{
"username" : "Ricky Grimmes",
"password" : "rg0123455"
}]
Please help thank you.