LoadRunner12常用函数

1、web_submit_data

Performs an "unconditional" or "contextless" form submission.
执行无条件或无上下文的表单提交。

In the following example, the web_submit_data function submits a form using the POST method:

web_submit_data("default.aspx",

    "Action=http://lazarus/flightnet/default.aspx",

    "Method=POST",

    "TargetFrame=",

    "RecContentType=text/html",

    "Referer=http://lazarus/flightnet/",

    "Snapshot=t7.inf",

    "Mode=HTML",

    ITEMDATA,

    "Name=grpType", "Value=radRoundtrip", ENDITEM,

    "Name=lstDepartingCity", "Value=DEN", ENDITEM,

    "Name=lstDestinationCity", "Value=LAX", ENDITEM,

    "Name=txtDepartureDate", "Value=8/19/2003", ENDITEM,

    "Name=txtReturnDate", "Value=8/19/2003", ENDITEM,

    "Name=txtQuantity", "Value=1", ENDITEM,

    "Name=radClass", "Value=1", ENDITEM,

    "Name=radSeat", "Value=1", ENDITEM,

    "Name=btnAvailableFlights", "Value=Next >", ENDITEM,

    LAST );
2、web_reg_save_param_ex 关联函数
web_reg_save_param_ex(
    "ParamName=spe_id",
    "LB=\",id:\"",
    "RB=\",deliveryType:",
    SEARCH_FILTERS,
    "Scope=BODY",
    LAST);
3、lr_save_string("1100", "barCode_add1"); // 将字符串“1100”保存到变量barCode_add1
4、lr_output_message(lr_eval_string("{barCode_add1}")); // 返回参数中当前的值,并输出
5、web_custom_request

Allows you to create a custom HTTP request with any method supported by HTTP.

In the following recorded script, the user began recording from http://lazarus/html/forms/file.html. When the user submitted his request, VuGen inserted a web_add_header function, followed by a web_custom_request function.
web_url("file.html", "URL=http://lazarus/html/forms/file.html",
    "TargetFrame=_TOP", LAST );
web_add_header("Content–Type",
"multipart/form–data; boundary=–––––––––––––––––––––––––––292742461228954");
web_custom_request("post_query.exe", "Method=POST",
    "URL=http://lazarus/cgi–bin/post_query.exe",
    "Body=–––––––––––––––––––––––––––––292742461228954\r\nContent–Disp"
    "osition: form–data; name=\"entry\"\r\n\r\nText\r\n––––––––––"
    "–––––––––––––––––––292742461228954\r\nContent–Disposition: f"
    "–––––––––––292742461228954––\r\n",
    "TargetFrame=",
    LAST );
6、lr_save_datetime

Assigns the current date and time to a parameter.

In the following example, lr_save_datetime retrieves tomorrow's date.

    lr_save_datetime("Tomorrow is %B %d %Y", DATE_NOW + ONE_DAY, "next");
    lr_output_message(lr_eval_string("{next}"));
7、lr_rendezvous

Creates a rendezvous point in the Vuser script.

In the following example, the lr_rendezvous function sets the Meeting rendezvous point. When all users that belong to the Meeting rendezvous arrive at the rendezvous point, they perform do_transaction simultaneously.

lr_rendezvous("Meeting");
    do_transaction(); /* application dependent transaction */
8、web_reg_find

Registers a search for a text string on an HTML page.

In the following example, web_reg_find searches for the text string "Welcome". If the string is not found, it fails and the script execution stops.
 web_reg_find("Text=Welcome",
        LAST );

Adds, deletes, or replaces a cookie.

web_add_cookie("ASP.NET_SessionId=w3u3hpsczsmzewgnraznejzj; DOMAIN=192.168.14.38"); // 把有验证码页面的request中的cookie存入即可登录。
10、lr_save_var
lr_save_var(lr_eval_string("{timestamp}")+6,4,0,"year");    // 从第6个字符开始截取4个字符,起始字符为0,保存到变量year中
11、rand 生成随机数
The following example generates 2 random numbers, each kept within a specific range using the mod (%) operator.

    // Srand is called before rand 

    srand(time(NULL)); 

    // Generate some random numbers 

    lr_output_message ("A number between 0 and 100: %d\n", rand() % 100); 

    lr_output_message ("A number between 20 and 30: %d\n", rand() % 10+20); 

转载于:https://www.cnblogs.com/liuliu3/p/9916512.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值