gpt4 book ai didi

robotframework - 将返回值附加到 Robot Framework 中的列表

转载 作者:行者123 更新时间:2023-12-03 20:17:28 48 4
gpt4 key购买 nike

我的测试步骤创建了 5 个工作线程来将文件上传到服务器,并为每个线程返回服务器 HTTP 响应代码。
我想将这些附加到每个步骤的响应代码列表中。

TC001_Single_User_Upload
[Documentation] Uploading single file by single user
${result} single user test file upload test_file.txt test1 test
Append To List @{RESPONSE_LIST} ${result}
${result} single user test file upload test_file.txt test1 test
Append To List @{RESPONSE_LIST} ${result}
log variables
log many @{RESPONSE_LIST}

我当前的日志文件显示:
20171127 13:59:01.911 - INFO - @{RESPONSE_LIST} = [ ]
20171127 13:59:01.911 - INFO - @{result} = [ <Response [201]> | <Response [201]> | <Response [201]> | <Response [201]> | <Response [201]> ]

问:为什么我的@{RESPONSE_LIST} 是空的?

最佳答案

Append to list 的第一个参数需要是一个列表对象。当您使用 @ ,这就像您将列表中的每个元素都作为一个新参数一样。

解决方法是更改​​@$ :

Append To List  ${RESPONSE_LIST}    ${result}

来自 robot framework user guide :

When a variable is used as a scalar like ${EXAMPLE}, its value will be used as-is. If a variable value is a list or list-like, it is also possible to use as a list variable like @{EXAMPLE}. In this case individual list items are passed in as arguments separately.

关于robotframework - 将返回值附加到 Robot Framework 中的列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47520868/

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