Re: Need to execute javascript using JMeter

Dmitri T <[email protected]> Wed, 2 Apr 2025 14:20:05 +0000
Newsgroups gmane.comp.jakarta.jmeter.user
Message-ID <SA3PR05MB10372C81F76109DC6DD02F10CC0AF2@SA3PR05MB10372.namprd05.prod.outlook.com>
--_000_SA3PR05MB10372C81F76109DC6DD02F10CC0AF2SA3PR05MB10372na_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

  1.
You answered your own question: JavaScript code cannot be run in JMeter.


  1.
Also, if you're  on Java 15+ you won't be able able to choose JavaScript in=
 JSR223 test elements because it has been removed from JDK<https://openjdk.=
org/jeps/372>
  2.
There could be inconsistencies between Postman JavaScript API and JMeter so=
 you won't have access to pm. namespace in JMeter


So you either need to restore JavaScript engine by adding Mozilla Rhino<htt=
ps://github.com/mozilla/rhino> or switching to GraalVM<https://www.graalvm.=
org/> or  re-write your code in Groovy. The latter option is better from pe=
rformance perspective as Groovy scripts can be compiled and cached and it m=
atters especially for "heavy" tasks like cryptography. More information: Ap=
ache Groovy: What Is Groovy Used For?<https://www.blazemeter.com/blog/apach=
e-groovy>



________________________________
From: Abhitosh Patil <[email protected]>
Sent: Wednesday, April 2, 2025 5:14 PM
To: JMeter Users List <[email protected]>
Subject: Need to execute javascript using JMeter

We have a requirement to generate unique authentication signature to pass
as a header in API request. We have a pre-request javascript for same in
postman tool.

Same javascript we tried in JMeter using jsr223 and beanshell elements. But
it's not working. Any solution for this?

--_000_SA3PR05MB10372C81F76109DC6DD02F10CC0AF2SA3PR05MB10372na_--