作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我写了这个测试,我在后台系统中发布了一份契约(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'
最佳答案
如果您使用 RequestsLibrary , 它建立在 python requests 之上图书馆。该库返回一个响应对象,但该对象没有 body
属性。这就是你得到 AttributeError 的原因。
如果需要结构化数据,可以使用 ${response.json()}
,如果需要原始文本,可以使用 ${response.text}
作为字符串的响应。
关于robotframework - 机器人框架 - 骑行 : Post Request unable to get response body,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40343726/
我写了这个测试,我在后台系统中发布了一份契约(Contract)。我用 forloop 创建了一个关键字,它从系统文件夹中获取 xml。 为了使测试通过,我想检查 de response 中的值。当我
我是一名优秀的程序员,十分优秀!