LR参数化

Loadrunner参数化

理解一下撒是参数化~

参数化就是把我们的请求数据动态化 ,不让他保持固定的,用来模拟真实的用户请求

以下发帖内容参数化示例~

1、首先点击如图所示图标,点击new按钮添加参数
在这里插入图片描述

2、点击Parameter type下拉框,选择参数格式此处以Random Number为例
在这里插入图片描述

3、设置Random的范围(此处设置为1~100),点击Number选项选择随机数展示格式
在这里插入图片描述

4、修改脚本,取设置的参数
在这里插入图片描述

5、设置显示参数log日志,方便调试
在这里插入图片描述

6、点击回放,回放结果如下~ 日志如下~
在这里插入图片描述
在这里插入图片描述

实例实践完成,咱来总结下LR常用的参数化方式~

Loadrunner常用的参数化方式
1、随机数
2、唯一数
3、文件
Select next row:用什么方式取值:how
Sequential(顺序)
Random(随机)
Unique(唯一)

Update value on:什么时候更新参数 :when
Each iteration(每次迭代)
Each occurrence(每次遇到)
Once(只一次)

ps:以下是脚本Action部分内容~

Action()
{

	web_set_max_html_param_len("1024");

	/* Registering parameter(s) from source task id 3
	// {JSESSIONID2} = "09A6C8EC93ED7C21DE971A01DDE928A5"
	// */

	web_reg_save_param("JSESSIONID2", 
		"LB/IC=jsessionid=", 
		"RB/IC=\"", 
		"Ord=1", 
		"Search=body", 
		"RelFrameId=1", 
		LAST);

	web_url("userAction_loginUI.action", 
		"URL=http://localhost:8080/TestOA/userAction_loginUI.action", 
		"TargetFrame=", 
		"Resource=0", 
		"RecContentType=text/html", 
		"Referer=", 
		"Snapshot=t1.inf", 
		"Mode=HTML", 
		EXTRARES, 
		"Url=style/blue/images/login_bg.gif", ENDITEM, 
		"Url=style/blue/images/login.gif", ENDITEM, 
		LAST);

	web_submit_data("userAction_login.action;jsessionid=09A6C8EC93ED7C21DE971A01DDE928A5", 
		"Action=http://localhost:8080/TestOA/userAction_login.action;jsessionid={JSESSIONID2}", 
		"Method=POST", 
		"TargetFrame=", 
		"RecContentType=text/html", 
		"Referer=http://localhost:8080/TestOA/userAction_loginUI.action", 
		"Snapshot=t2.inf", 
		"Mode=HTML", 
		ITEMDATA, 
		"Name=loginName", "Value={username}", ENDITEM, 
		"Name=password", "Value={password}", ENDITEM, 
		"Name=x", "Value=47", ENDITEM, 
		"Name=y", "Value=20", ENDITEM, 
		EXTRARES, 
		"Url=style/blue/images/top_bg.gif", "Referer=http://localhost:8080/TestOA/homeAction_top.action", ENDITEM, 
		"Url=style/blue/images/head2_bg.gif", "Referer=http://localhost:8080/TestOA/homeAction_top.action", ENDITEM, 
		"Url=style/blue/images/menu_btn_bg.gif", "Referer=http://localhost:8080/TestOA/homeAction_left.action", ENDITEM, 
		LAST);

	web_url("论坛", 
		"URL=http://localhost:8080/TestOA/forumAction_list.action", 
		"TargetFrame=right", 
		"Resource=0", 
		"RecContentType=text/html", 
		"Referer=http://localhost:8080/TestOA/homeAction_left.action", 
		"Snapshot=t3.inf", 
		"Mode=HTML", 
		EXTRARES, 
		"Url=style/blue/images/title_bg.gif", ENDITEM, 
		"Url=style/blue/images/title_bg_head.gif", ENDITEM, 
		"Url=style/blue/images/inputPageHeadBg.gif", ENDITEM, 
		"Url=style/blue/images/title_bg_end.gif", ENDITEM, 
		LAST);

	web_url("技术交流", 
		"URL=http://localhost:8080/TestOA/forumAction_show.action?id=1", 
		"TargetFrame=", 
		"Resource=0", 
		"RecContentType=text/html", 
		"Referer=http://localhost:8080/TestOA/forumAction_list.action", 
		"Snapshot=t4.inf", 
		"Mode=HTML", 
		EXTRARES, 
		"Url=style/blue/images/pageSelector_bg.gif", "Referer=http://localhost:8080/TestOA/forumAction_show.action?id=1", ENDITEM, 
		LAST);

	web_url("publishNewTopic.png", 
		"URL=http://localhost:8080/TestOA/topicAction_addUI.action?forumId=1", 
		"TargetFrame=", 
		"Resource=0", 
		"RecContentType=text/html", 
		"Referer=http://localhost:8080/TestOA/forumAction_show.action?id=1", 
		"Snapshot=t5.inf", 
		"Mode=HTML", 
		LAST);

	web_url("fckeditor.html", 
		"URL=http://localhost:8080/TestOA/fckeditor/editor/fckeditor.html?InstanceName=content&Toolbar=bbs", 
		"TargetFrame=", 
		"Resource=0", 
		"RecContentType=text/html", 
		"Referer=http://localhost:8080/TestOA/topicAction_addUI.action?forumId=1", 
		"Snapshot=t6.inf", 
		"Mode=HTML", 
		EXTRARES, 
		"Url=../fckconfig.js", "Referer=http://localhost:8080/TestOA/fckeditor/editor/fckeditor.html?InstanceName=content&Toolbar=bbs", ENDITEM, 
		"Url=js/fckeditorcode_ie.js", "Referer=http://localhost:8080/TestOA/fckeditor/editor/fckeditor.html?InstanceName=content&Toolbar=bbs", ENDITEM, 
		"Url=../myconfig.js", "Referer=http://localhost:8080/TestOA/fckeditor/editor/fckeditor.html?InstanceName=content&Toolbar=bbs", ENDITEM, 
		"Url=lang/zh-cn.js", "Referer=http://localhost:8080/TestOA/fckeditor/editor/fckeditor.html?InstanceName=content&Toolbar=bbs", ENDITEM, 
		"Url=skins/default/fck_editor.css", "Referer=http://localhost:8080/TestOA/fckeditor/editor/fckeditor.html?InstanceName=content&Toolbar=bbs", ENDITEM, 
		"Url=skins/default/images/toolbar.collapse.gif", "Referer=http://localhost:8080/TestOA/fckeditor/editor/fckeditor.html?InstanceName=content&Toolbar=bbs", ENDITEM, 
		"Url=skins/default/images/toolbar.expand.gif", "Referer=http://localhost:8080/TestOA/fckeditor/editor/fckeditor.html?InstanceName=content&Toolbar=bbs", ENDITEM, 
		"Url=skins/default/images/toolbar.start.gif", "Referer=http://localhost:8080/TestOA/fckeditor/editor/fckeditor.html?InstanceName=content&Toolbar=bbs", ENDITEM, 
		"Url=skins/default/fck_strip.gif", "Referer=http://localhost:8080/TestOA/fckeditor/editor/fckeditor.html?InstanceName=content&Toolbar=bbs", ENDITEM, 
		"Url=skins/default/images/toolbar.buttonarrow.gif", "Referer=http://localhost:8080/TestOA/fckeditor/editor/fckeditor.html?InstanceName=content&Toolbar=bbs", ENDITEM, 
		"Url=../fckstyles.xml", "Referer=http://localhost:8080/TestOA/fckeditor/editor/fckeditor.html?InstanceName=content&Toolbar=bbs", ENDITEM, 
		LAST);

	web_submit_data("topicAction_add.action", 
		"Action=http://localhost:8080/TestOA/topicAction_add.action", 
		"Method=POST", 
		"TargetFrame=", 
		"RecContentType=text/html", 
		"Referer=http://localhost:8080/TestOA/topicAction_addUI.action?forumId=1", 
		"Snapshot=t7.inf", 
		"Mode=HTML", 
		ITEMDATA, 
		"Name=forumId", "Value=1", ENDITEM, 
		"Name=title", "Value=我的测试发帖标题{title}", ENDITEM, 
		"Name=content", "Value=我的测试发帖内容{content}", ENDITEM, 
		"Name=x", "Value=24", ENDITEM, 
		"Name=y", "Value=16", ENDITEM, 
		LAST);
	return 0;
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值