Friday, June 7, 2013

How to convert plain text into URL format in Loadrunner?

Sometimes while parametrization and correlation we need to put a check on the type of value that is being passed. And we need to convert the format of the variable. For this we have a function in LoadRunner web_convert_param this function either converts HTML text to plain text or URL, or converts plain text to URL.

The syntax of web_convert_param is as:

int web_convert_param( const char *ParamName, [char *SourceString] char *SourceEncoding, char *TargetEncoding, LAST );
In the below example we are converting string "Plain text to be converted to URL" to URL format from plain format.

Example:
Click here to know more

Action()
{

char param1[]="Plain text to be converted to URL";

lr_save_string(param1, "Input");

lr_output_message("The value of input is : %s",lr_eval_string("{Input}"));
web_convert_param("Input","SourceEncoding=PLAIN","TargetEncoding=URL", LAST );

lr_output_message("The value after converting is : %s",lr_eval_string("{Input}"));
return 0;

}

The output will be as :

 The following table shows same content in the three formats :
HTML
URL
Plain Text
<mytag>&
%3Cmytag%3E%26
<mytag>&

That’s all for today :). Thanks for reading guys!!!

No comments:

Post a Comment