gpt4 book ai didi

karate - 在 Karate 测试的路径中使用逗号

转载 作者:行者123 更新时间:2023-12-04 10:54:45 28 4
gpt4 key购买 nike

使用以下测试用例

Background:
* callonce read('auth.feature')
* url java.lang.System.getenv('TEST_URL')

Scenario: Call the file endpoint without authorization

Given path 'files/123695_11,8'
When method get
Then status 401

我收到有关不匹配引号的解析器错误。原因可能是“路径”被逗号混淆了,因为它也可以用来表示子路径。

我想只是改变 ,%2C ,但随后空手道使用 % 调用 URL编码为 %25 ,导致 URL 错误 'files/123695_11%252C8'其解码为字面意思 'files/123695_11%2C8' .

我怎样才能使这个工作正常?

最佳答案

最简单的选项,合并到url :

* url 'https://httpbin.org/anything/files/123695_11,8'
* method get

我知道你可能想在后台“重用”东西,所以使用变量:
Background:
* def baseUrl = 'https://httpbin.org/anything'

Scenario:
* url baseUrl + '/files/123695_11,8'
* method get

黑客解决方法:
* url 'https://httpbin.org/anything'
* def temp = 'files/123695_11,8'
* path temp
* method get

关于karate - 在 Karate 测试的路径中使用逗号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59282714/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com