Robotframework:如何检索请求的答案 [英] Robotframework : How to retrieve the answer of a request

查看:119
本文介绍了Robotframework:如何检索请求的答案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想测试用户的激活.为了验证用户的创建,我单击有效"按钮,前端请求后端发送POST请求.
我的目标是检索此查询的答案.

I would like to test the activation of a user. To validate the creation of a user, I click on a "Valid" button and the front-end requests the back-end to send a POST request.
My goal is to retrieve the answer to this query.

我尝试了以下关键字:

*** Setting ***
Library    SeleniumLibrary
Library    HttpLibrary.HTTP    

*** Keyword ***
!Confirm entry
    [Arguments]    ${id_button}
    Wait Until Element Is Visible    ${id_button}
    Click Element    ${id_button}
    Response Status Code Should Equal    200

*** Setting ***
Library    SeleniumLibrary

*** Keyword ***
!Confirm entry
    [Arguments]    ${id_button}
    Wait Until Element Is Visible    ${id_button}
    ${status}    Run Keyword And Return    Click Element    ${id_button}

这两个解决方案使我不满意.
请问您对在Robotframework中用来解决我的问题的关键字有所了解吗?

These two solutions don't give me satisfaction.
Would you, please, have an idea of the keywords to use in Robotframework to solve my problem?

最诚挚的问候

推荐答案

Click Element将不会返回您期望的状态代码.您无法使用硒获取状态代码.

Click Element will not return status code as you expected. You can't get the status code using selenium.

Response Status Code Should Equal是HTTP库,仅在遵循HTTP请求(例如HTTP库中的GETPOST关键字)时才适用.

Response Status Code Should Equal is HTTP library and it will work for only when it is followed HTTP Request like GET,POST keywords in HTTP library.

Example      
    HTTP Context    httpstat.us
    GET  /302
    Response Status Code Should Equal   302

它不适用于硒关键字.

It will not work with selenium keywords.

这篇关于Robotframework:如何检索请求的答案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆