Highlighted
Frequent Contributor.
Frequent Contributor.
100 views

VIMP:Web(Http/html)-JS Error:Error when executing javascript function with web_js_run()

Hi,

In my scenario, developpers implemented JWT  token decode functionality in Client side  by using Java script.

I got that java script code for jwt token decode and when i try to execute using web_js_run(),It giving following error:

Test.js:6:TypeError: window.atob is not a function  [MsgId: MERR-26000]
Action.c(4): Error -35051: Failed to run the JavaScript code [MsgId: MERR-35051]

the JS  engine used by LR is unable to identify the window.atob() function. But this is working fine in browser console and other js  consoles.

Im pasting js code here. please have a look and help me on this ASAP.

Js File:  Test.js

----------------------

function decodeJWT(jwtToken)
{
    const base64Url = jwtToken.split('.')[1];
    const base64 = base64Url.replace('-', '+').replace('_', '/');
    const token = window.atob(base64);
  
    return token;
  }

Implementaion on Action.c file

------------------------------------- 

   web_js_run(
        "Code=decodeJWT('eyJraWQiOiIxIiwiYWxnIjoiUlM1MTIifQ.epI....some... xxxxx');",
        "Resultparam=JwtDecodeDeatils",
        SOURCES,
        "file=Test.js", 
         ENDITEM,LAST);   
    return 0;

Please help me on this.

Regards

Maheswar

 

 

0 Likes
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: VIMP:Web(Http/html)-JS Error:Error when executing javascript function with web_js_run()

Hello,

It might be because window is a browser element and not a pure JavaScript element.

Regardless of that, since you are looking into testing web applications from the HTTP level and you are familiar with JavaScript so you might want to give DevWeb a look. It is a new LoadRunner protocol exactly for these purposes.

Regards,

Gil

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.