您的位置:首页 > 其它

LR 关联函数的边界值可以为参数

2014-04-23 16:51 211 查看
参数可以作为关联函数的边界值,有如下好处:

1)非常方便查找一些新建的值,并且可以同步处理新建立的数据

2)在controller中并发时,解决了数据不同步问题,可以让每个虚拟并发用户只处理自己的数据,不会出现两个虚拟用户抢到一个数据从而报错的情况

-----------------------------------------

新建一个数据的脚本:注意 {flowname}
参数


Action()

{

  lr_save_string("192.168.10.108:8080","IP");

web_url("{IP}",
"URL=http://{IP}/",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t3.inf",
"Mode=HTML",
EXTRARES,
"URL=/Public/js/jquery-1.11.0.min.js", "Referer=http://{IP}/login/index", ENDITEM,
"URL=/Public/font/fontawesome-webfont.eot?", "Referer=http://{IP}/login/index", ENDITEM,
"URL=/Public/img/back.jpg", "Referer=http://{IP}/login/index", ENDITEM,
LAST);

lr_think_time(3);

lr_start_transaction("login");

web_submit_data("check_login",
"Action=http://{IP}/login/check_login",
"Method=POST",
"TargetFrame=",
"RecContentType=text/html",
"Referer=http://{IP}/login/index",
"Snapshot=t5.inf",
"Mode=HTML",
ITEMDATA,
"Name=emp_no", "Value=admin", ENDITEM,
"Name=password", "Value=123456", ENDITEM,
LAST);

web_find("web_find",
"What=登录成功!",
LAST);

web_url("index",
"URL=http://{IP}/index/index",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://{IP}/login/check_login",
"Snapshot=t7.inf",
"Mode=HTML",
LAST);

lr_end_transaction("login", LR_AUTO);

lr_think_time(3);

lr_start_transaction("新建流程");

/*点击流程*/

// web_add_cookie("Hm_lpvt_2a935166b0c9b73fef3c8bae58b95fe4=1397875109; DOMAIN=192.168.10.108");

/*
web_custom_request("server",
"URL=http://{IP}/push/server",
"Method=POST",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://{IP}/push/client",
"Snapshot=t8.inf",
"Mode=HTML",
"EncType=application/x-www-form-urlencoded; charset=UTF-8",
"Body=&ajax=1",
LAST);

*/

/*点击新建*/

// web_add_cookie("current_node=144; DOMAIN=192.168.10.108");

web_url("index_2",
"URL=http://{IP}/flow/index",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://{IP}/home/index",
"Snapshot=t9.inf",
"Mode=HTML",
LAST);

/*选择流程*/

// web_add_cookie("ace.settings=%7B%22sidebar-collapsed%22%3A-1%7D; DOMAIN=192.168.10.108");

// web_add_cookie("Hm_lpvt_2a935166b0c9b73fef3c8bae58b95fe4=1397875145; DOMAIN=192.168.10.108");

// web_add_cookie("return_url=http%3A//192.168.10.108%3A8080/flow/index; DOMAIN=192.168.10.108");

// lr_think_time(12);

web_url("27",
"URL=http://{IP}/flow/add/type/27",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://{IP}/flow/index",
"Snapshot=t12.inf",
"Mode=HTML",
// EXTRARES,
// "URL=/Public/editor/themes/default/default.css", ENDITEM,
// "URL=/Public/editor/themes/default/default.png", ENDITEM,
LAST);

// lr_think_time(3);

/*点击提交*/

// lr_think_time(12);

web_submit_data("save",
"Action=http://{IP}/flow/save",
"Method=POST",
"EncType=multipart/form-data",
"TargetFrame=",
"RecContentType=text/html",
"Referer=http://{IP}/flow/add/type/27",
"Snapshot=t19.inf",
"Mode=HTML",
ITEMDATA,
"Name=ajax", "Value=0", ENDITEM,
"Name=add_file", "Value=", ENDITEM,
"Name=type", "Value=27", ENDITEM,
"Name=opmode", "Value=add", ENDITEM,
"Name=confirm", "Value=emp_3002|", ENDITEM,
"Name=confirm_name", "Value=\r\n"
"\t\t\t\t<span id=\"emp_3002\" data=\"emp_3002\"><nobr><b title=\"经理3002/经理<>\">经理3002/经理<></b></nobr></span>\t\t\t", ENDITEM,
"Name=consult", "Value=emp_3001|emp_3002|emp_2002|emp_3001|", ENDITEM,
"Name=consult_name", "Value=\r\n"
"\t\t\t\t<span id=\"emp_3001\" data=\"emp_3001\"><nobr><b title=\"经理3001/经理<>\">经理3001/经理<></b></nobr><b><i class=\"icon-arrow-right\"></i></b><b><i class=\"icon-arrow-right\"></i></b><b><i class=\"icon-arrow-right\"></i></b></span><span
id=\"emp_3002\" data=\"emp_3002\"><nobr><b title=\"经理3002/经理<>\">经理3002/经理<></b></nobr><b><i class=\"icon-arrow-right\"></i></b><b><i class=\"icon-arrow-right\"></i></b></span><span id=\"emp_2002\" data=\"emp_2002\"><nobr><b title=\"总监2002/总监<>\">总监2002/总监<></b></nobr><b><i
class=\"icon-arrow-right\"></i></b></span><span id=\"emp_3001\" data=\"emp_3001\"><nobr><b title=\"经理3001/经理<>\">经理3001/经理<></b></nobr></span>\t\t\t", ENDITEM,
"Name=refer", "Value=", ENDITEM,
"Name=refer_name", "Value=\r\n"
"\t\t\t\t\t\t\t", ENDITEM,
"Name=step", "Value=20", ENDITEM,
"Name=name", "Value=flow{flowname}", ENDITEM,
"Name=content", "Value=性能测试流程-group2", ENDITEM,

bf7a
LAST);

web_find("web_find",
"What=新增成功!",
LAST);

web_url("跳转",
"URL=http://{IP}/flow/index",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://{IP}/flow/save",
"Snapshot=t20.inf",
"Mode=HTML",
LAST);

lr_end_transaction("新建流程", LR_AUTO);

/*logout*/

lr_think_time(3);

web_url("logout", 
"URL=http://{IP}/login/logout", 
"TargetFrame=", 
"Resource=0", 
"RecContentType=text/html", 
"Referer=http://{IP}/flow/index", 
"Snapshot=t22.inf", 
"Mode=HTML", 
LAST);

return 0;

}

-------------------

数据建立成功后,用该参数作为关联函数的边界值来取同一个数据进行下一步处理:

Action2()

{

lr_save_string("192.168.10.108:8080","IP");

web_url("{IP}",
"URL=http://{IP}/",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t3.inf",
"Mode=HTML",
EXTRARES,
"URL=/Public/js/jquery-1.11.0.min.js", "Referer=http://{IP}/login/index", ENDITEM,
"URL=/Public/font/fontawesome-webfont.eot?", "Referer=http://{IP}/login/index", ENDITEM,
"URL=/Public/img/back.jpg", "Referer=http://{IP}/login/index", ENDITEM,
LAST);

// web_add_cookie("Hm_lvt_2a935166b0c9b73fef3c8bae58b95fe4=1397875058,1397875084; DOMAIN=192.168.10.108");

// web_add_cookie("Hm_lpvt_2a935166b0c9b73fef3c8bae58b95fe4=1397875084; DOMAIN=192.168.10.108");

lr_think_time(3);

lr_start_transaction("login");

web_submit_data("check_login",
"Action=http://{IP}/login/check_login",
"Method=POST",
"TargetFrame=",
"RecContentType=text/html",
"Referer=http://{IP}/login/index",
"Snapshot=t5.inf",
"Mode=HTML",
ITEMDATA,
"Name=emp_no", "Value=3002", ENDITEM,
"Name=password", "Value=123456", ENDITEM,
LAST);

web_find("web_find",
"What=登录成功!",
LAST);

web_url("index",
"URL=http://{IP}/index/index",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://{IP}/login/check_login",
"Snapshot=t7.inf",
"Mode=HTML",
LAST);

lr_end_transaction("login", LR_AUTO);

web_set_max_html_param_len("1024");

lr_think_time(3);

lr_start_transaction("checkflow");

// web_add_cookie("Hm_lpvt_2a935166b0c9b73fef3c8bae58b95fe4=1397877445; DOMAIN=192.168.10.108");

/*
web_custom_request("server",
"URL=http://{IP}/push/server",
"Method=POST",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://{IP}/push/client",
"Snapshot=t8.inf",
"Mode=HTML",
"EncType=application/x-www-form-urlencoded; charset=UTF-8",
"Body=&ajax=1",
EXTRARES,

// "URL=http://hm.baidu.com/hm.gif?cc=1&ck=1&cl=24-bit&ds=1366x768&ep=48329%2C3877&et=3&fl=11.6&ja=1&ln=zh-cn&lo=0<=1397877429&nv=0&rnd=2018131183&si=2a935166b0c9b73fef3c8bae58b95fe4&st=4&su=http%3A%2F%2F192.168.10.108%3A8080%2Flogin%2Fcheck_login&v=1.0.57&lv=3",
"Referer=http://{IP}/home/index", ENDITEM,
LAST);

*/

/*点击流程*/

/*点击待审批*/

// web_add_cookie("current_node=147; DOMAIN=192.168.10.108");

web_reg_save_param("flow_id",
"LB=/flow/read/id/",
"RB=\">flow{flowname}",
"Ord=ALL",
"Search=Body",

 //     "NotFound=WARNING",
LAST);

web_url("confirm",
"URL=http://{IP}/flow/folder/fid/confirm",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://{IP}/home/index",
"Snapshot=t9.inf",
"Mode=HTML",
LAST);

if(0==atoi(lr_eval_string("{flow_id_count}"))) {

lr_output_message("There is no flow to check : %s", lr_eval_string("The flow_id_count: {flow_id_count}"));

}

else {

lr_save_string( lr_paramarr_random("flow_id"),
"flow_random" );

// web_add_cookie("Hm_lpvt_2a935166b0c9b73fef3c8bae58b95fe4=1397877495; DOMAIN=192.168.10.108");

// web_add_cookie("return_url=http%3A//192.168.10.108%3A8080/flow/folder/fid/confirm; DOMAIN=192.168.10.108");

/*选择一个流程*/

lr_output_message("There flow_id_count  %s-------------------------------------", lr_eval_string("is: {flow_id_count}"));

lr_output_message("There flow_random  %s-------------------------------------", lr_eval_string("is: {flow_random}"));

web_url("{flow_random}",//初始值=131
"URL=http://{IP}/flow/read/id/{flow_random}",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://{IP}/flow/folder/fid/confirm",
"Snapshot=t13.inf",
"Mode=HTML",
EXTRARES,
"URL=/Public/editor/themes/default/default.css", ENDITEM,
"URL=/Public/editor/themes/default/default.png", ENDITEM,
LAST);

// web_add_cookie("Hm_lpvt_2a935166b0c9b73fef3c8bae58b95fe4=1397877513; DOMAIN=192.168.10.108");

/*点击同意*/

// web_add_cookie("return_url=/flow/read/id/131; DOMAIN=192.168.10.108");

web_reg_find("Search=Body",
"SaveCount=check_count",
"Text=操作成功",
LAST);

web_submit_data("approve",
"Action=http://{IP}/flow/mark/action/approve",
"Method=POST",
"TargetFrame=",
"RecContentType=text/html",
"Referer=http://{IP}/flow/read/id/{flow_random}",
"Snapshot=t16.inf",
"Mode=HTML",
ITEMDATA,
"Name=id", "Value=155", ENDITEM,
"Name=flow_id", "Value={flow_random}", ENDITEM,
"Name=step", "Value=21", ENDITEM,
"Name=comment", "Value=", ENDITEM,
LAST);

web_url("跳转",
"URL=http://{IP}/flow/read/id/{flow_random}",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=http://{IP}/flow/mark/action/approve",
"Snapshot=t17.inf",
"Mode=HTML",
LAST);

lr_end_transaction("checkflow", LR_AUTO);

}//else

/*logout*/

lr_think_time(3);

web_url("logout", 
"URL=http://{IP}/login/logout", 
"TargetFrame=", 
"Resource=0", 
"RecContentType=text/html", 
"Referer=http://{IP}/flow/index", 
"Snapshot=t22.inf", 
"Mode=HTML", 
LAST);

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: