Robotframework under Httplibrary Library other key words

Source: Internet
Author: User

 

 

 

 

Key words

Usage description

DELETE

Sends an HTTP delete request to the server that receives a parameter [url] that is very similar to the POST request, as an example:

DELETE

/_utils/config.htm

HEAD

Sends an HTTP HEAD request to the server that receives a parameter [url] that is very similar to a GET request, as an example:

HEAD

/_utils/config.htm

PUT

Sends an HTTP PUT request to the server that receives a parameter [url] that is very similar to the POST request, as an example:

PUT

/_utils/config.htm

Get Json Value

Get the value of a node in a JSON string, example:

${value}

Get Json value

{"Foo": {"bar": []}}

/foo/bar

should be Equal

${value}

[1, 2, 3]

 

 

 

Json Value should Equal

This is an assertion keyword that is used to determine whether a node of a JSON string corresponds to a value that is expected to be consistent, example:

${json}

Set Variable

{"Foo": {"bar": [ [+]}}

 

 

Json Value should Equal

${json}

/foo/bar

[1, 2, 3]

 

Json Value should not Equal

This is an assertion keyword that is used to determine whether a node of a JSON string corresponds to a value that is not expected to be inconsistent, when it is inconsistent, execution succeeds, or execution fails, example:

${json}

Set Variable

{"Foo": {"bar": [By ]}}

 

 

Json Value should not Equal

${json}

/foo/bar

[ 1, 2, 3]

 

Log Response Body

Prints the Response body content after the HTTP request is executed, which is typically used after a POST request or a GET request is issued. The request receives a parameter [Log_level=info], which, by default, uses the INFO level to print the log when there are no incoming log level parameters.

Log Response Headers

Prints the Response headers content after the HTTP request is executed, which is typically used after a POST request or a GET request is issued. The request receives a parameter [Log_level=info], which, by default, uses the INFO level to print the log when there are no incoming log level parameters.

Log Response Status

Prints the Response status Status code after the HTTP request is executed, which is typically used after a POST request or a GET request is issued. The request receives a parameter [Log_level=info], which, by default, uses the INFO level to print the log when there are no incoming log level parameters.

Response Body should contain

This is an assertion keyword that is used to determine what should be included in the response Body after an HTTP request response, which receives a parameter [Should_contain (contains)], example:

Table border= "1" cellspacing= "0" cellpadding= "0" >

GET

/foo.xml

Response Body should contain

Versi On= "1.0"

Response Body should contain

encoding= "UTF-8"

Response Header should Equal

This is an assertion keyword that is used to determine if the response header after the HTTP request response is the same as expected, and the keyword receives two parameters [Header_name | expected], example:

Table border= "1" cellspacing= "0" cellpadding= "0" >

respons E Header should Equal

Content-type

text/html; Charset=utf-8

Response headers should not Equal

This is an assertion keyword, and the usage and response header should equal just the opposite, to determine whether the response header after the HTTP request response is inconsistent with the expected On inconsistency, execution succeeds, no execution fails, the keyword receives two parameters [Header_name | not_expected], example:

Respon Se Header should Equal

Content-type

text/html; Charset=utf-8

 

Response should has Header

This is an assertion keyword that is used to determine whether the response header in the HTTP request response contains the expected header name, which receives a parameter [Header_name], example:

Table border= "1" cellspacing= "0" cellpadding= "0" >

respons E should have Header

Content-type

Response should not having Header

This is an assertion keyword that is used to determine whether the response header after the HTTP request response does not contain the expected header name, which receives a parameter [Header_name], example:

response should not has Header

Content-type

 

Response Status Code should Equal

This is an assertion keyword that is used to determine whether the response status code after the HTTP request response is the same as expected, and the keyword receives a parameter [Status_code], example:

Table border= "1" cellspacing= "0" cellpadding= "0" >

respons E Status Code should Equal

$

Response Status Code should not Equal

This is an assertion keyword that is used to determine if the response status code after the HTTP request response is inconsistent with the expected, if the execution succeeds in the case of an inconsistency, if the execution fails, the keyword receives a parameter [Status_code], example:

Response Status Code should not Equal

200

Set Http Host

This keyword is used to set the host name of the HTTP request, which is rarely used now, and it is recommended to use the Create HTTP context keyword instead of that keyword.

Set Basic Auth

The basic Auth when the keyword is used to set HTTP requests (the basic Auth simple point description is that the user's username and password are provided each time the API is requested.) ), the keyword receives two parameters [username | password]

Set Json Value

This keyword is used to set the value of a node in a JSON string, example:

${json}

Set json Value

{" foo ": {" bar ": []}}

/foo

should be equal< /strong>

${json}

{" Foo ":--}

 

 

Log Json

This keyword is used to print the contents of a JSON string, example:

 

tbody> Equal

{"Foo": {"bar": [[i]}}

INFO

stringify Json

This keyword is used to convert data to a JSON-form string, example:

${data}

Create List

A b c

${json_string}

stringify J SON

${data}

log

${json_string}

 

 

Show Response Body in Browser

Use the default browser to display the response body of the last HTTP request

should be Valid Json

The keyword is an assertion keyword that is used to determine if a string is a valid JSON string, as an example:

should be Valid Json

["A B C"]

Parse Json

This keyword is used to parse a JSON string, example:

${json}

Parse Json

{"Foo": {"bar": []}}

log

${json}

 

 

Next Request should succeed

This keyword is used to determine that, in the presence of multiple requests, the next request should be executed successfully, when using the keyword, there is a general need for at least two requests, HTTP requests, many requests have a feature, that is idempotent, such as GET request, Head requests, etc., are idempotent requests, that is, execute once and execute multiple times, should be successful, the results should be consistent. When the HTTP code>=400 is returned when the second HTTP request is executed, the second request execution failure is considered, example:

GET

/ user/signin/aa.htm

Next Request should succeed

 

GET

/user/signin/aa.htm

 

Next Request should not succeed

This keyword is used to determine that, in the presence of multiple requests, the next request should not be successful, when using the keyword, there is a general need to have at least two requests, HTTP requests, there are many requests are non-idempotent, such as common post requests is a typical non-idempotent request that executes once and executes multiple times, and the result of execution is not necessarily consistent. When the HTTP code<400 is returned when the second HTTP request is executed, the second execution of the request is considered successful, example:

POST

/user/signin

Next Request should not succeed

 

POST

/user/signin

 

Next Request should has Status Code

This keyword is used to determine whether the next HTTP request returns the same code value as expected when there are multiple requests, example:

POST

/user/signin

Next Request Sho Uld has Status Code

302

POST

/user/signin

 

Next Request may not succeed

This keyword is similar to the next request should succeed keyword, which typically requires at least two requests and, when the next request returns an HTTP code>=400, that the next request is a failed execution. Example:

POST

/user/signin

Next Request may not succeed

POST

/user/signin

Robotframework under Httplibrary Library other key words

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.