loadrunner中的web_convert_param函数

某些场景中获取的参数、自定义参数直接作用于请求的body或url时将不会被特殊的转换为页面编码一致的字符串,导致提交至服务的拼接字符串格式不正确,我们就可以将字符串转为url或html中的格式。

注: 不确定自己发送的参数是否与服务器接收的参数是否一致时:

如果是公司的系统直接问开发
把自己使用的参数输出,在Tree模式下找到录制时请求的data,与自己输出的内容比对格式是否一致
把自己使用的参数输出,在浏览器中找到请求的data,与自己输出的内容比对格式是否一致
使用fidder类的工具抓取请求data进行比对
int web_convert_param( const char *ParamName, [char *SourceString] char *SourceEncoding, char *TargetEncoding, LAST ); 
ArgumentDescription
Description(描述)The name of a parameter. The converted string will be saved in this parameter. If SourceString is not used, it initially contains the text to convert. Note that this is not a name–value pair. Pass only the name of the parameter.
SourceString(源字符串)A literal string to convert. “SourceString=your text”
SourceEncoding(源编码)The encoding type of the source data: HTML, URL, or plain text, in the format:“SourceEncoding=HTML” “SourceEncoding=URL” or"SourceEncoding=PLAIN"
TargetEncoding(目标编码)The target data format: URL, HTML, or plain text, in the format:“TargetEncoding=URL”“TargetEncoding=HTML"or"TargetEncoding=PLAIN”
LASTA marker indicating the end of the argument list.

示例:
将参数 demo进行转换

Action()
{
	char * str = "090;789;04/18/2019";
	lr_save_string(str, "demo");
	web_convert_param("demo", "SourceEncoding=PLAIN", "TargetEncoding=URL", LAST );
	lr_output_message("%s", lr_eval_string("{demo}"));
	return 0;
}

执行结果:
	090%3B789%3B04%2F18%2F2019

转载于:https://www.cnblogs.com/weibgg/p/10786935.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值