LOADRUNNER11 Testing RESTful

Source: Internet
Author: User
Tags closing tag

LoadRunner don't know why there's such a big volume.

Started with a C script, but the disgusting is not a complete C, read the file fseek incredibly not.

Then toss Java script, found that loadrunner11 Java to use JDK 1.6 and is 32-bit, and finally started.

The syntax is perfect for Java.

Import the package that comes with LoadRunner first.

Import LRAPI.LR;
Import Lrapi.web;

Logical code is just like normal Java, very handy.

Web.reg_save_param Save the data returned by the request, the first parameter is equivalent to the saved variable, and the second is the filter condition.

We're going back to JSON, which can parse the JSON directly through a third-party library, but only some of the fields in JSON, the JSON parsing, is a bit of a hassle.

"lb=version\": "," rb=, ", LB represents the beginning of the search, which is represented here from version": Start looking, RB means end, leave blank for the end, quotation marks "to be escaped with," last "represents the closing tag.
Remove the saved value with lr.eval_string ("<ResponseBody>").
Web.reg_save_param ("Responsebody",Newstring[]{"lb=version\": "," rb=, "," Search=body "," Last "}); String HtmlBody= "Body=loadtest=1&param={\" userid\ ": 1790}"; Try{web.custom_request ("Apply/check",                     This. Reqtype,Newstring[]{"Url=http://192.168.18.227/apply/check", "Method=post", HtmlBody,//String Object is not in quotes"Last"}); String result= Lr.eval_string ("<ResponseBody>"); returnresult; } Catch(Exception e) {return""; }

For the C language version, the LR. or Web. Prefix is changed to Lr_ or web_

LOADRUNNER11 Testing RESTful

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.