HTTP interface test for LoadRunner.

Source: Internet
Author: User

1, first we need to know whether the test interface is GET or post form:

2,get Request:

1) Use the Web_url function.

2) in LoadRunner press F1 help document, find Web_url function, and then see the example of the function, find an instance paste it over, change can write script.

It is very convenient to know the function name in this case.

3) Web_url function writing: Know the request address, either self-grabbed the package, or there is a request address document.

4) Write the enhanced script: things, assembly points, checkpoints, parameterization, if judgments, and so on.

Convert the LoadRunner variable to the C language string:lr_eval_string ("{row_cnt}");




Convert String to int:

int i;

char * s = "7 dollars";

i = atoi(s);

Lr_output_message ("Price $%d", I);






Comparison of two strings:

int strcmp (string1, string2);





2,post Request: Parameter is Josn

Web_custom_request: Name, method, URL, body this is necessary, others see the situation plus.

For example: The document describes the interface in this way:

Url:http://localhost:8080/perfteach/postmethod

Parameters: data={"username": "Jack", "password": "123"}



So

Web_custom_request ("Postquery",

"Method=post",

"Url=http://localhost:8080/perfteach/postmethod",

"Body=data={\" username\ ": \" Jack\ ", \" password\ ": \" 123\ "}"

last);


Once you have finished, run it again to see what the return value is.


You can then strengthen the script: things, set points, checkpoints, parameterization, if judgments, and so on.





POST request: Key-value pair form

Web_submit_data ("Postquery2",

"Action=http://localhost:8080/perfteach/postmethod",

"Method=post",

ItemData,

"Name=method", "Value=getpaymentdata", Enditem,

"Name=paramjson", "value=[\" 3b9455c49648cd4f0bd37c115e30ff19,\ "]", Enditem,

last);




HTTP interface test for LoadRunner.

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.