API测试返回InvalidURL:非数字端口:robot框架

时间:2018-12-03 18:50:31

标签: robotframework

我第一次使用带有机器人框架的Library HttpLibrary.HTTP。 我的api网址类似于:
https://www.app.com:8080/rest/api/customer/phone/personnalData
当我用谷歌浏览器打开此网址时,它会作为响应 {"phone":false}

我尝试对机器人框架做同样的事情:

Create Http Context https://www.app.com:8080/rest/api/customer/phone  /personnalData 
Set Request Header    Content-Type    application/json
Set Request Header    Accept    application/json
HttpLibrary.HTTP.GET    https://www.app.com:8080/rest/api/customer/phone  /personnalData 
${Body}=    HttpLibrary.HTTP.Get Response Body
JSON.Save Json    ${Body}    C:/RESTResponseBody.json

我得到了这个回应:
    [ FAIL | InvalidURL: nonnumeric port: '9448/rest/api/customer/phone/personnalData' ]

请帮忙。

1 个答案:

答案 0 :(得分:1)

您需要通过以下方式使用http lib。

Create Http Context      host=www.app.com:8080   scheme=https 
Set Request Header    Content-Type    application/json
Set Request Header    Accept    application/json
HttpLibrary.HTTP.GET    /rest/api/customer/phone  /personnalData 
${Body}=    HttpLibrary.HTTP.Get Response Body
JSON.Save Json    ${Body}    C:/RESTResponseBody.json