LoadRunner之VuGen检查点

检查点

说明:检查点是在回放脚本期间搜索指定的文本或图片,从而验证服务器响应数据的正确性;
提示:
    1). LR中的检查点的使用-是调用 web_reg_find()函数
    2). 在LR中使用检查点的时候必须开启 Enable Image and text check(启用图片和文本检查)
    3). 要使用检查点录制模式必须是HTML-based mode 且为 web_submit_form模式

1 、函数 web_reg_find()

说明:web_reg_find为LR检查点函数;
参数:
    1. Text:要检查的文本内容【必填】
    2. Search:搜索响应数据范围- ALL、Body、Header【选填】
    3. Fail:失败条件-NotFound/Found 【选填】
    4. SaveCount:匹配结果数量且返回到参数中【选填】
注意:
    1. 函数包含reg为注册函数,注册函数必须放到依赖执行函数之前(依赖:函数运行后的数据给注册函数使用)

2 、需求操作分析

1. 使用HTML-based mode 且为 web_submit_form模式录制登录
2. 开启 Enable Image and text check(启用图片和文本检查)
3. 在特定位置插入检查点函数 web_reg_find()

3 、需求操作实施

1) 使用HTML-based mode 模式

 2) 开启 Enable Image and text check

 3) 插入检查点函数 web_reg_find()

参数:
    1. Search for specific Text:搜索特定文本
    2. Search in:搜范范围 
                 1). All :搜索Body+Headers
                 2). Body:只搜索Body
                 3). Headers:只搜索Headers
    3. Save count:搜索满足条件的数量,并保存在指定的参数名中
    4. Fail if:检查失败的条件
                1). NotFound 没有找到检查失败 -推荐
                2). Found 找到了检查失败

 代码

Action()
{

	//处理动态session
	web_reg_save_param("Session",
		"LB=name=userSession value=",
		"RB=>",
		LAST);

	//打开webTours首页
	web_url("首页","URL=http://127.0.0.1:1080/WebTours/",LAST);

    //检查点
	web_reg_find("Text=jojo",
		LAST);

	//登录操作
	web_submit_data("登录",
		"Action=http://127.0.0.1:1080/WebTours//login.pl",
		"Method=POST",
		"TargetFrame=",
		"Referer=",
		"Mode=HTML",
		ITEMDATA,
		"Name=userSession", "Value={Session}", ENDITEM,
		"Name=username", "Value=jojo", ENDITEM,
		"Name=password", "Value=bean", ENDITEM,
		LAST);

	return 0;
}

运行结果

Action.c(5): 注册 web_reg_save_param 成功  	[MsgId: MMSG-26390]
Action.c(11): 在“http://127.0.0.1:1080/WebTours/”中检测到非资源“http://127.0.0.1:1080/WebTours/header.html”  	[MsgId: MMSG-26574]
Action.c(11): 在“http://127.0.0.1:1080/WebTours/”中检测到非资源“http://127.0.0.1:1080/WebTours/welcome.pl?signOff=true”  	[MsgId: MMSG-26574]
Action.c(11): 在 HTML“http://127.0.0.1:1080/WebTours/header.html”中找到资源“http://127.0.0.1:1080/WebTours/images/hp_logo.png”  	[MsgId: MMSG-26659]
Action.c(11): 在 HTML“http://127.0.0.1:1080/WebTours/header.html”中找到资源“http://127.0.0.1:1080/WebTours/images/webtours.png”  	[MsgId: MMSG-26659]
Action.c(11): 在“http://127.0.0.1:1080/WebTours/welcome.pl?signOff=true”中检测到非资源“http://127.0.0.1:1080/WebTours/nav.pl?in=home”  	[MsgId: MMSG-26574]
Action.c(11): 在“http://127.0.0.1:1080/WebTours/welcome.pl?signOff=true”中检测到非资源“http://127.0.0.1:1080/WebTours/home.html”  	[MsgId: MMSG-26574]
Action.c(11): 在 HTML“http://127.0.0.1:1080/WebTours/nav.pl?in=home”中找到资源“http://127.0.0.1:1080/WebTours/images/mer_login.gif”  	[MsgId: MMSG-26659]
Action.c(11): web_url("首页") 已成功,6448 个正文字节,1562 个标头字节  	[MsgId: MMSG-26386]
Action.c(14): 注册 web_reg_find 成功  	[MsgId: MMSG-26390]
Action.c(18): 在“http://127.0.0.1:1080/WebTours//login.pl”中检测到非资源“http://127.0.0.1:1080/WebTours//nav.pl?page=menu&in=home”  	[MsgId: MMSG-26574]
Action.c(18): 在“http://127.0.0.1:1080/WebTours//login.pl”中检测到非资源“http://127.0.0.1:1080/WebTours//login.pl?intro=true”  	[MsgId: MMSG-26574]
Action.c(18): 在 HTML“http://127.0.0.1:1080/WebTours//nav.pl?page=menu&in=home”中找到资源“http://127.0.0.1:1080/WebTours/images/flights.gif”  	[MsgId: MMSG-26659]
Action.c(18): 在 HTML“http://127.0.0.1:1080/WebTours//nav.pl?page=menu&in=home”中找到资源“http://127.0.0.1:1080/WebTours/images/itinerary.gif”  	[MsgId: MMSG-26659]
Action.c(18): 在 HTML“http://127.0.0.1:1080/WebTours//nav.pl?page=menu&in=home”中找到资源“http://127.0.0.1:1080/WebTours/images/in_home.gif”  	[MsgId: MMSG-26659]
Action.c(18): 在 HTML“http://127.0.0.1:1080/WebTours//nav.pl?page=menu&in=home”中找到资源“http://127.0.0.1:1080/WebTours/images/signoff.gif”  	[MsgId: MMSG-26659]
Action.c(18): 注册的 web_reg_find 对于“Text=jojo”成功(计数=1)  	[MsgId: MMSG-26364]
Action.c(18): web_submit_data("登录") 已成功,5693 个正文字节,1538 个标头字节  	[MsgId: MMSG-26386]
正在结束操作 Action。
正在结束迭代 1。
正在结束 Vuser...
正在开始操作 vuser_end。
正在结束操作 vuser_end。
Vuser 已终止。

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值