RobotFramework creates Test Case corresponding to POST Request

Take a look at the finished product:

1. The keyword required to create a POST Request is " POST Request "

2. If there is a body, you need to add "data=${body}" after the URI. ${body} is the variable name of the body defined by me. The content can be a string or a dict, and it will be displayed at the end. are all data in json format.

But the most important thing is that if the body corresponding to the URL is already in json format, we must add the header field to the URL, which must contain: " Content-Type=application/json ".

So when I define the variable ${headers}, you can see that I have created a dictionary, where UserId and ApiKey are the fields that the URL needs to verify, which is business logic, but Content-Type must be added Yes, this has nothing to do with the business, but with the body style.

3. To get the name of the current Test Case, use the Robot Framework built-in variable "${TEST NAME}". (If you want to get the name corresponding to the Test Suite, you can use the built-in variable "${SUITE NAME}".

4. The complete information of which line of Post request is finally sent is as follows:

${resp}=    Post Request    QAEnv    /v1/models/morn-123456-ReducedRiskModel/exposures    data=${body}    params=${params}    headers=${headers}

The "${resp}=" of the first cell means: assign the response returned by the Post to the variable resp.

If you don't need to get the response, you can delete the cell.

 

It's simple, you get it O(∩_∩)O haha~

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325304494&siteId=291194637