Robotframework 机器人框架-乘坐:Post请求无法获取响应正文

Robotframework 机器人框架-乘坐:Post请求无法获取响应正文,robotframework,Robotframework,我写了这个测试,我在后台系统中发布了一份合同。我用forloop创建了一个关键字,它从systemfolder中提取XML 为了使测试通过,我想检查de response中的值。当我使用RF/Ride执行此测试时,不可能获得响应库,如果我在Postman/SoapUI中执行相同的测试,我可以看到响应库 当我请求response.headers时,我得到了预期的数据 骑乘测试: *** Test Cases *** XML [Template] Template post contr

我写了这个测试,我在后台系统中发布了一份合同。我用forloop创建了一个关键字,它从systemfolder中提取XML

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

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

骑乘测试:

*** 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
邮递员回应:

<?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>
  • 我的测试是否有导致此错误的错误
  • 有没有人遇到过同样的问题?你的解决方案是什么
  • 如果您正在使用,它将构建在python库之上。此库返回一个响应对象,但该对象没有
    body
    属性。这就是为什么你会得到AttributeError


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

    您使用的是什么库?返回带有
    body
    属性的对象是否有文档记录?标准python请求库不返回带有
    body
    属性的对象。我们使用requestslibrary。这是一个很好的问题,我的同事也用过,他也用过。他的api给出了json响应和我的xml。我检查了库,但找不到任何关于返回对象的信息
    FAIL : Resolving variable '${response.body}' failed: AttributeError: 'Response' object has no attribute 'body'