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.