Highlighted
Absent Member.
Absent Member.
741 views

Using Javascript in LoadRunner scripts

Hi All,

I am using js file in one of my script to encrypt password and a few other parameters. Below is snippet from the code which shows how the request is handled.

Sessionid, token are captured using correlation & password is parameterised.

char *pwd;

char *sessionID;

char *token;

sessionID=lr_eval_string("{correlated_sessionID_param}");

token=lr_eval_string("{correlated_token_param}");

web_js_run(

"code=function('pwd','sessionID','token')",

"ResultParam=param",

SOURCES,

"File=File.js", ENDITEM,

LAST);

 

The issue is that, instead of the pwd, sessionID, token values, string "pwd", "sessionID", "token" are being passed to the javascript file. 

Please help how I can send the values to js file.

 

Thanks in advance.

 

Regards,

Umesh

 

0 Likes
2 Replies
Highlighted
Absent Member.
Absent Member.

Re: Using Javascript in LoadRunner scripts

Hi Umesh,

If you're using LoadRunner version 12.50 or higher, you can generate/write the entire script in JavaScript, thus avoiding the need to use web_js_run and simplifying the use of JS snippets. Check out this blog post:

http://community.hpe.com/t5/LoadRunner-and-Performance/Empowering-LoadRunner-with-JavaScript-or-C-as-a-scripting/ba-p/6777925#.V1-YWaIgHQY

 

0 Likes
Highlighted
Super Contributor.
Super Contributor.

Re: Using Javascript in LoadRunner scripts

Hi umeshkamble,

you are feeding the call web_js_run() a string which will be interpreted. This string conatins the names of those variables you mentioned.

Have you tried feeding the VALUES of the variables into the web_js_run() call instead?

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.