Ramar
Ramar

Reputation: 1564

Use dynamic value in Postman test script

I have a postman test script to use with test runner. I am trying to pass dynamic value from file to validate response with no success. I am able to pass value to request, but not able to use value from data file in test script. I want to validate response with data passed from CSV file. Is something like below possible in first place?

pm.test("Body matches string", function () {

    pm.expect(pm.response.text()).to.include('{{$column1}}');

});

Upvotes: 1

Views: 698

Answers (1)

Ramar
Ramar

Reputation: 1564

Found that variable usage in test script is different. Below works.

pm.test("Body matches string", function () {

    pm.expect(pm.response.text()).to.include(pm.variables.get("column1"));

});

Upvotes: 1

Related Questions