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

Deadly 提交于 2019-12-09 22:38:20

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/45422335/karate-api-tests-escaping-in-the-url-in-a-feature-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!