空手道 API 测试 - 转义“?"在功能文件的 url 中 [英] Karate API Tests - Escaping '?' in the url in a feature file

查看:14
本文介绍了空手道 API 测试 - 转义“?"在功能文件的 url 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用来自 Karate API 框架的 path 关键字来连接字符串以形成一个 url.但是,我无法通过?".这是我正在做的事情:

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

当我运行测试时,我看到了?"作为 %3F 传递.我尝试使用 来逃避它,并尝试了其他一些答案,但未能成功.我需要使用 url 编码吗?任何指示或帮助将不胜感激.谢谢

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

推荐答案

这种情况你应该使用param:

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

这篇关于空手道 API 测试 - 转义“?"在功能文件的 url 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆