1

I faced problem with checking specific key. For example I have the next response

    {
    "content": [
        {
            "first_name": "Agent007",
            "last_name": "007",
            "id": "aa70d1c0-3de4",
            "status": "INACTIVE"
        },
        {
            "first_name": "ALEX",
            "last_name": "Doe",
            "id": "d9d5c211-5388",
            "status": "ACTIVE"
        }
    ]

}

How to check if each "status" can have "ACTIVE" OR "INACTIVE" value?

I tried this, but it doesn't work

And assert response.content[*].status == 'ACTIVE' || response.content[*].status == 'INACTIVE'
Holgar
  • 91
  • 5

1 Answers1

0

This is (just) one way to do it:

* match each response.content[*].status == "#? _ == 'INACTIVE' || _ == 'ACTIVE'"

Also refer the docs: https://github.com/karatelabs/karate#match-each

And see this answer for advanced ideas: https://stackoverflow.com/a/70055035/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248