Highlighted
Contributor.
Contributor.
403 views

javascript is not working as expected in loadrunner v12.50

Team,

I'm using the below function in action part to test javascript. LR failed to execute 
Action()
{

    web_js_run(
         "Code= var a=1234; var n=a.length; alert(n); ",
          "ResultParam=uri",
    LAST);
     return 0;
}

Output:
 Starting action Action.
Action.c(4): web_js_run started [MsgId: MMSG-26355]
Alert from JS (len=9): undefined
Action.c(4): web_js_run was successful [MsgId: MMSG-26392]
Ending action Action

Answer should 9 but I used to get undefined. 
Could anyone please help on this to resolve the issue. Thanks 

Note: Enabled javaEngine in RUNTIME 

 

Tags (2)
0 Likes
1 Reply
Highlighted
Frequent Contributor.
Frequent Contributor.

Re: javascript is not working as expected in loadrunner v12.50

Hello,

The varaiable "a" appears to be a number by your defination, pleae try change it to:  

  web_js_run(
         "Code= var a='1234'; var n=a.length; alert(n); ",
          "ResultParam=uri",
    LAST);

 

Regards,

Bingle(LoadRunner R&D)

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.