Shubham
Shubham

Reputation: 33

can we use json file as datatable in karate?

I'm trying to make datatable values dynamic using json file.

Can anybody help with dynamic datatable creation? I want to get the datatable values from json file.

Here is my code:

Scenario Outline: get all users and then get the first user by id

Given path 'users'

And request read('request.json')

When method post

Then status 201

Examples:
| kittens |

And: Kittens.json

{
    "id" : "11"
}

Upvotes: 1

Views: 579

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58088

Please read the docs carefully, and there are examples: https://github.com/intuit/karate#dynamic-scenario-outline

Change kittens.json to the below (note that it has to be a JSON array, see the square brackets):

[{ id: 11 }]

And then this should work:

Examples:
| read('kittens.json') |

Upvotes: 2

Related Questions