Highlighted
Super Contributor.. Super Contributor..
Super Contributor..
1037 views

Use Parameter value in web.url Function

Hello,

I am using Loadrunner 12.53 and HTTP/HTML protocol.

This function saves the parameter and display it in Output log.

web.regSaveParamEx({         paramName: 'Id',         lb:'someText /',         value: '',         rb:'}',

        scope: 'body',          ordinal: 'all',     });

The output log shows;

Notify: Saving Parameter "Id_1 = 12344".

Notify: Saving Parameter "Id_2 = 13455".

Notify: Saving Parameter "Id_3 = 14566".

Notify: Saving Parameter "Id_count = 3". 

I want to use Id_1, Id_2, and Id_3 value in my web.url function. If I write {Id_1} it works, but how to work in a dynamic way.

For example: web.url function should take the Id values from the output log one after another.

web.url(

{

name : 'TestId',

url : '....//test.com/..../{Id}',   // {id} will give error because It does not know which value to use.

resource : 0, 

recContentType : 'text/html', 

referer : '',

snapshot : 't8.inf'

}

);

Could anyone can help?

Thanks

0 Likes
3 Replies
Highlighted
Regular Contributor.. Regular Contributor..
Regular Contributor..

Re: Use Parameter value in web.url Function

Hello, Skumar1.

I encountered a similar problem before. For my instance, I had to check the whole array to see the current ID of a specifc info that I was looking for.

What I did was to get first the count of the returned result.

// get number of matches, array index starts at 1; also you should declare int RUIDcount first at the start of your script
RUIDcount = atoi(lr_eval_string("{RUID_count}"));

Then I created a for loop to traverse the results.
for (i = 1; i <= RUIDcount; i++) {
// create full name of a current parameter
sprintf(CurrentRUID, "{RUID_%d}", i);
if(strstr(lr_eval_string(CurrentRUID), "tokenIwastryingtofind") != NULL) {
lr_output_message("Dropdown value found.");
lr_save_int(i,"NewParameter");
break;
}
}

I will then now use the {NewParameter} in my web.url function.

Regards,

Jane

0 Likes
Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Re: Use Parameter value in web.url Function

Hello Jane,

Thanks for your kind response.

I am working with web http/HTML and the code language is JavaScript.

JavaScript does not support “atoi, sprint and strstr”.

Thanks

0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Use Parameter value in web.url Function

Hi

Being an oldtimer, I use C for programming so I can't help you with the exact syntax.

But you should use the lr.paramarrRandom function. For example/reference check here:

http://lrhelp.saas.hpe.com/en/12.53/help/function_reference/FuncRef.htm#js_vuser/lrFr_JS_lr_paramarrRandom.htm#Example

br /ola

.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.