简体   繁体   中英

Can I use for loop in karate?

I am using get request for getting json response. And it is dynamic. My response looks like this.

{
    "data": [
        {
            "id": 1,
            "name": "Jack",
            "gender": "male"
        },
        {
            "id": 2,
            "name": "Jill",
            "gender": "female"
        }
    ]
}

Can I use id from this response and put that id in 'for loop' to execute delete method? Given path 'profile/delete/id' And if I can then how?

Yes, refer the docs: https://github.com/intuit/karate#data-driven-features

* def result = call read('delete.feature') response.data

And in delete.feature you will be able to refer to the id variable directly.

I am using get request for getting json response. And it is dynamic. My response looks like this.

{
    "data": [
        {
            "id": 1,
            "name": "Jack",
            "gender": "male"
        },
        {
            "id": 2,
            "name": "Jill",
            "gender": "female"
        }
    ]
}

Can I use id from this response and put that id in 'for loop' to execute delete method? Given path 'profile/delete/id' And if I can then how?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM