Search code examples
apirequestkarateoutlinescenarios

How to get values for one column from scenario outline as an array in Karate


I have a request.json as below

    {
    "country":"#(country)",
    "states":["#(states)"]
    }

My feature file

    Scenario outline: test

    *def req = call('request.json')
    And request req
    When method post

    Examples:
    |country|states|
    |India|delhi,goa|

With above code I am getting as

    {
    "country":"India",
    "states":["delhi,goa"]
    }

But i want my request to look like below

    {
    "country":"India",
    "states":["delhi","goa"]
    }

Is there any direct way to get above request.


Solution

  • Make this change:

    Examples:
    |country|states!|
    |India|['delhi','goa']|
    

    Refer: https://github.com/intuit/karate#scenario-outline-enhancements