• 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
    Content–Disp"
        "osition: form–data; name="entry"
    
    Text
    ––––––––––"
        "–––––––––––––––––––292742461228954
    Content–Disposition: f"
        "–––––––––––292742461228954––
    ",
        "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
    ", rand() % 100); 
    
        lr_output_message ("A number between 20 and 30: %d
    ", rand() % 10+20); 
    
    
  • 相关阅读:
    基于XMPP实现的Openfire的配置安装+Android客户端的实现
    Android之基于XMPP协议即时通讯软件
    【Android XMPP】 学习资料收集贴(持续更新)
    R-ArcGIS探秘(1)安装以及Sample执行
    如何打造新媒体微营销平台
    29淘宝论坛推广技巧
    win10 UWP button
    Tomcat 6.x Perm区内存泄露问题
    Android WebView开发常见问题
    创建类模式大PK(总结)
  • 原文地址:https://www.cnblogs.com/liuliu3/p/9916512.html
Copyright © 2020-2023  润新知