1

Trying to pass dynamic path parameters from CSV for a GET method.

Referring to Karate: how to pass dynamic path parameters?

we are trying to pass dynamic parameter in path from a CSV file, but it doesn't work well when method is GET, although for POST we don't have an issue using CSV.

here elaborating with help of a open API

Feature: Get users details based on valid and invalid inputs from csv file

  Background:

  * url 'https://reqres.in'

    Scenario Outline: Get single user based on id value - Valid & invalid
      Given path '/api/users/<id>'

      When method <method>
      Then status <status>

      * print response
      ##* match response.data.id contains <id>

      Examples:
        |id|status|method|Scenario|
        |2|200|GET|Valid id as input|
        |4|200|GET|Valid id as input|
        |5|200|GET|Valid id as input|
        |&|404|GET|Special character as Input|
        | |404|GET|Empty space as Input|
        |A|404|GET|Alphabet as input|
        |999|404|GET|Invalid Number as input|
        |-1|404|GET|Invalid Number as input|

This works well, but when I try to pass same data with following it doesn't work

  |read('../../Data/users.csv')|

this is how this CSV looks users data csv file

1 Answers1

0

It is hard to say from the data given, and it doesn't work is not helpful. Maybe special characters cause problems. The best thing would be to follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

In general I discourage using a Scenario Outline for negative cases. Some guidance can be found here: https://stackoverflow.com/a/54126724/143475

To troubleshoot the CSV, you can try * print __row to see the values in each row.

This works for me:

Scenario Outline:
* url 'https://httpbin.org'
* path 'post'
* request __row
* method post

Examples:
| read('test.csv') |
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248