Questions tagged [postman-testcase]
283 questions
0
votes
1 answer
How to verify the length of attributes in an array and make sure no extra attributes are displayed?
I have verified the length of input as var resp =(body.input).length and make sure it is not 0. But I also want to verify only firstname,lastname and rollno is available in each set and the count will be always 3. How to I verify this is postman…

Lakshmi
- 17
- 1
- 6
0
votes
0 answers
How to Extract values for Testscripts from XML Response in postman
failed to capture the value of name which is "userinfo"
//this what I tried as for eg to extract the name: "userInfo" from xml response
var jsonObject = xml2Json(responseBody);
pm.environment.set("name",…

CypressAuto
- 31
- 1
- 3
0
votes
0 answers
How to read model's schema and validate in postman test script
I have a model schema and i want to read those and validate in postman test script.
could you please share your suggestions ?

Ranjeet
- 49
- 8
0
votes
1 answer
How to write a test for nested JSON response from enterprise application
I'm trying to use Postman as a test tool to validate that our customers all have a mailing address in our master system. I'm having trouble drilling down into the JSON due to its structure. Each response is an array structure with a single "node"…

James Mattheiss
- 3
- 2
0
votes
1 answer
Not able to get values of postman global variable
I am able to set global variable but unable to get that.
pm.sendRequest(getLibraries, function (err, response) {
if(!err){
var jsonData = response.json();
console.log('Libraries: ',jsonData);
var lib_id =…

Ranjeet
- 49
- 8
0
votes
1 answer
True / false written on console , trying to write tests in postman. If false, fail the test
I have contains function that prints in console as true/ false, I need to write a tests in postman so that if found false, fail the tests and can be shown on tests tab. In the below const testfalse= gives the value true or false in console. But if…

Aditya K
- 3
- 2
0
votes
0 answers
how to verify boolean value in postman with or and And conditions
the response can be either true or false. I need to pass the test whether it's true or false in the response but it should check the condition if the value is true to pass the test as well as if false
script i am using is but not working
…

Taha Iqbal
- 5
- 3
0
votes
0 answers
Postman pre-request everything is working fine as expected but facing below Undefined error
There was an error in evaluating the Pre-request Script: Error: Cannot read property 'name' of undefined
var limit = 50;
pm.sendRequest(getComponentsNewURL, function (err, response) {
var jsonData = response.json();
…

Ranjeet
- 49
- 8
0
votes
0 answers
How to write a nested test case in postman?
For Example, if below is my response:
{
"rule":"1001",
"fixedResponse":"101JOB0011102JOB0012"
}
Based on fixedResponse field value, can I create a test case like a function within a function for each job validation?
pm.test("Validate…

Vivek Rangaraj
- 13
- 4
0
votes
1 answer
Delete Postman Cookies
Is there any way to expire authtoken in postman saved after login call?
I have tried to code get response object
{
tests["Login successfull"] = responseCode.code === 200;
var token = postman.getResponseCookie("authtoken");
console.log(token)
}
this…
0
votes
3 answers
Postman - Get response value using variable key
I've created a GET request in Postman that returns some data in a JSON format. I want to get the JSON response value for every key that contains a specific substring.
This is the code I've been trying:
var jsonData = pm.response.json();
var keys =…

MADi
- 23
- 8
0
votes
1 answer
Assign a value from Json response array object to environment variable in Postman
I have a JSON body response that has an array object in it.
{
"tokens": [
{
"baseValue": "need this value to be extracted"
}
]
}
The following test script is not able to extract it and set it in the…

mack
- 345
- 5
- 18
0
votes
2 answers
Find Postman sub-object based on property
I'd like to get the first item which has "shipping":"ABC" in the response below. In this case, the expected response should be 37
I'm not very good at writing Javascript test in Postman.
Thank you.
{
"37": {
"shipping_id": 37,
…

Quang T
- 15
- 6
0
votes
1 answer
Postman Testing Scripts: How to change env variable after one test case?
So my issue is that I want to have 2 tests for a single api call - one pass and one fail with missing params.
Here is what I have:
pm.test("Successful Login", function () {
pm.response.to.have.status(200);
});
pm.test("Missing Parameters", function…

Naman Jain
- 321
- 5
- 21
0
votes
1 answer
I'm getting assertion error when using not.eql when running test from Postman collection
My main objective is to check VarA not suppose to match with VarB.
So I used assertion to check on this.
var jsonData = pm.response.json()
varA= jsonData.body.SubA
varB= jsonData.body.SubB
pm.expect (varA) .to.not.eql (varB)
It works fine with…

tqa
- 11
- 1
- 8