我寫了這個測試,我在後臺系統中發佈合同。我用forloop製作了一個關鍵字,它從系統文件夾中獲取xml。機器人框架 - 乘坐:發佈請求無法獲得響應主體
爲了使測試通過,我想檢查de響應中的值。當我使用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>
錯誤:
FAIL : Resolving variable '${response.body}' failed: AttributeError: 'Response' object has no attribute 'body'
- 我的測試是否有錯誤,導致此錯誤?
- 有沒有人遇到同樣的問題,你的解決方案是什麼?
你在使用什麼庫?是否記錄了返回一個具有'body'屬性的對象?標準的python請求庫不會返回具有'body'屬性的對象。 –
我們使用請求庫。那麼這是一個很好的問題,我的同事使用它,並與他一起工作。那麼他的api會給出json響應和我的xml。我檢查了圖書館,但找不到任何關於返回對象的信息,儘管 – Shizzleliz