Search code examples
cucumbergherkincucumber-javakarate

Karate API Tests - Escaping '?' in the url in a feature file


I am using the path keyword from Karate API framework to concatenate strings to form a url. However, I am not able to pass '?'. Here is what I am doing:

 Background: 
    * url 'https://api.cloud.abcde.com/animal/'

 Scenario: Verify the get status
    Given path 'herbivore?id=25'
    When method get
    Then status 200

When I run the test, i see the '?' being passed as %3F. I tried to escape it using \ and tried some other answers too but couldn't succeed. Do I need to use url encoding ? Any pointers or help would be appreciated. Thanks


Solution

  • You should use param for this case:

    Scenario: Verify the get status
        Given path 'herbivore'
        And param id = 25
        When method get
        Then status 200