遇一山,过一山,处处有风景;只要勇敢向前,一路尽是繁花盛开。 | (点击查看→)【测试干货】python/java自动化、持续集成、性能、测开、简历、笔试面试等

LoadRunner开发http协议接口之form表单脚本

 

loadrunner传form表单,用web_submit_data函数。

Action()
{
//     lr_start_transaction("hp_homepage");
//         web_url("hp_homepage","url=http://127.0.0.1:1080/WebTours/",LAST);
//     lr_end_transaction("hp_homepage", LR_AUTO);

    //web_reg_save_param("userSession","LB=name=userSession value=","RB=>","Search=body",LAST);
    web_reg_save_param_ex("ParamName=userSession","LB=name=userSession value=","RB=>",SEARCH_FILTERS,"Scope=body",LAST);

    lr_start_transaction("hp_webtours");
        web_url("hp_webtours","url=http://127.0.0.1:1080/WebTours/nav.pl?in=home",LAST);    
    lr_end_transaction("hp_webtours", LR_AUTO);

    lr_error_message("userSession=%s",lr_eval_string("{userSession}"));

    web_reg_save_param("result","LB=<frame src=","RB=?intro=true","Search=body",LAST);
    //web_reg_save_param("result","LB=login.pl?intro=","RB= ","Search=body",LAST);
    //判断事物的时候和true比较,if(strcmp(lr_eval_string("{result}"),"true")==0)

    lr_start_transaction("login");
        web_submit_data("login", 
        "Action=http://127.0.0.1:1080/WebTours/login.pl", 
        "Method=POST",
        "TargetFrame=", 
        "RecContentType=text/html", 
        "Referer=", 
        "Snapshot=t7.inf", 
        "Mode=HTML", 
        ITEMDATA, 
        "Name=userSession","Value={userSession}",ENDITEM,
        "Name=username","Value=jojo",ENDITEM,
        "Name=password","Value=bean",ENDITEM,
        "Name=login.x","Value=41",ENDITEM,
        "Name=login.y","Value=8",ENDITEM,
        "Name=login","Value=Login",ENDITEM,
        "Name=JSFormSubmit","Value=off",ENDITEM,
        LAST ); 
        //系统自动判断写为:lr_end_transaction("login", LR_AUTO);
        if(strcmp(lr_eval_string("{result}"),"login.pl")==0)//一般情况下,get请求不需要检查是否成功。
        {
            lr_end_transaction("login", LR_PASS);
            lr_error_message("log succes");
        }
        else{
            lr_error_message("log fail");
            lr_end_transaction("login", LR_FAIL);
            lr_error_message("log fail");
        }
    return 0;
}

  

posted @ 2019-06-08 09:48  全栈测试笔记  阅读(1208)  评论(0编辑  收藏  举报
浏览器标题切换
浏览器标题切换end