gpt4 book ai didi

robotframework - 机器人框架 - 骑行 : Post Request unable to get response body

转载 作者:行者123 更新时间:2023-12-01 11:22:48 26 4
gpt4 key购买 nike

我写了这个测试,我在后台系统中发布了一份契约(Contract)。我用 forloop 创建了一个关键字,它从系统文件夹中获取 xml。

为了使测试通过,我想检查 de response 中的值。当我使用 RF/Ride 执行此测试时,无法获得响应主体,如果我在 Postman/SoapUI 中执行相同的测试,我可以看到响应主体

当我请求 response.headers 时,我得到了预期的数据

Ride 中的测试:

*** Test Cases *** XML
[Template] Template post contract BO
apitest1.xml
*** Keywords *** Template post contract BO
[Arguments] @{bestandlijst}
: FOR ${bestand} IN @{bestandlijst}
\ &{headers}= Create dictionary Content-type=application/xml
\ ${bestandophalen}= Get Binary File ${bestand}
\ Create Session Backoffice https://url
\ ${response}= Post Request Backoffice /isCOBOL(API_V1_ARCONTRACT) headers=&{headers} data=${bestandophalen}
\ log ${response.headers} -> this works
\ log ${response.body} -> this doesn't work

Postman 中的响应:

<?xml version="1.0" encoding="UTF-8"?>
<Retourbericht xmlns="http://url/schemas/things">
<Statuscode>OK</Statuscode>
<Statusmelding>Contract opgeslagen in de backoffice.</Statusmelding>
<TransactionResponse>Onbekend.</TransactionResponse>
</Retourbericht>

骑行错误:

FAIL : Resolving variable '${response.body}' failed: AttributeError: 'Response' object has no attribute 'body'
  1. 我的测试是否有错误导致此错误?
  2. 有没有人遇到过同样的问题,您的解决方案是什么?

最佳答案

如果您使用 RequestsLibrary , 它建立在 python requests 之上图书馆。该库返回一个响应对象,但该对象没有 body 属性。这就是你得到 AttributeError 的原因。

如果需要结构化数据,可以使用 ${response.json()},如果需要原始文本,可以使用 ${response.text}作为字符串的响应。

关于robotframework - 机器人框架 - 骑行 : Post Request unable to get response body,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40343726/

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