Re: Need to execute javascript using JMeter
Christof <[email protected]> Thu, 03 Apr 2025 11:18:10 +0000
| Newsgroups | gmane.comp.jakarta.jmeter.user |
|---|---|
| Message-ID | <[email protected]> |
------16FBIY3PB5YIK01LS2XPK2BG3SJ6ID Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Abhitosh, is the javascript script small in size? If so you could remove or replace with dummies all hardcoded security rela= ted parts and attach the script in this channel=2E May be , that someone will take the challenge and migrate it to groovy =2E It it is 100 lines or more I will not have the time to do that=2E Otherwis= e I will give it a chance=2E Christof Am 3=2E April 2025 09:02:36 UTC schrieb Abhitosh Patil <abhitosh=2Eqa@gmai= l=2Ecom>: >Unfortunately ChatGPT or other AI tools are not allowed in our organisati= on >network=2E > >On Wed, 2 Apr, 2025, 9:04 pm Abhitosh Patil, <abhitosh=2Eqa@gmail=2Ecom> = wrote: > >> Thank you Chris=2E >> I'll check this possibility=2E >> >> On Wed, 2 Apr, 2025, 9:03 pm Christof, <c=2Eschmalenbach@perfomatics=2E= com> >> wrote: >> >>> Hi Abhitosh, >>> groovy is one of the supported languages in jsr223 sampler=2E If your >>> javascript has not thousand codelines, I'm very optimistic, that with = the >>> help of chatGPT you should be able to migrate your code >>> from js -> groovy=2E >>> regards >>> Christof >>> >>> >>> Am 2=2E April 2025 14:49:15 UTC schrieb Abhitosh Patil < >>> abhitosh=2Eqa@gmail=2Ecom>: >>> >Initially I was using Java 17 but later switched to java 8 >>> >Currently getting error like "javax=2Escript=2EscriptExecution: refer= ence >>> >error: pm is not defined=2E >>> > >>> >Rhino or Graalvm are not available on our company download portal=2E >>> > >>> >I don't know anything about Groovy=2E >>> > >>> >On Wed, 2 Apr, 2025, 8:10 pm Dmitri T, <glinius@live=2Ecom> wrote: >>> > >>> >> 1=2E >>> >> You answered your own question: JavaScript code cannot be run in >>> JMeter=2E >>> >> >>> >> >>> >> 1=2E >>> >> 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=2Eorg/jeps/372> >>> >> 2=2E >>> >> There could be inconsistencies between Postman JavaScript API and >>> JMeter >>> >> so you won't have access to pm=2E namespace in JMeter >>> >> >>> >> >>> >> So you either need to restore JavaScript engine by adding Mozilla >>> Rhino< >>> >> https://github=2Ecom/mozilla/rhino> or switching to GraalVM< >>> >> https://www=2Egraalvm=2Eorg/> or re-write your code in Groovy=2E T= he latter >>> >> option is better from performance perspective as Groovy scripts can= be >>> >> compiled and cached and it matters especially for "heavy" tasks lik= e >>> >> cryptography=2E More information: Apache Groovy: What Is Groovy Use= d >>> For?< >>> >> https://www=2Eblazemeter=2Ecom/blog/apache-groovy> >>> >> >>> >> >>> >> >>> >> ________________________________ >>> >> From: Abhitosh Patil <abhitosh=2Eqa@gmail=2Ecom> >>> >> Sent: Wednesday, April 2, 2025 5:14 PM >>> >> To: JMeter Users List <user@jmeter=2Eapache=2Eorg> >>> >> Subject: Need to execute javascript using JMeter >>> >> >>> >> We have a requirement to generate unique authentication signature t= o >>> pass >>> >> as a header in API request=2E We have a pre-request javascript for = same >>> in >>> >> postman tool=2E >>> >> >>> >> Same javascript we tried in JMeter using jsr223 and beanshell >>> elements=2E But >>> >> it's not working=2E Any solution for this? >>> >> >>> >> ------16FBIY3PB5YIK01LS2XPK2BG3SJ6ID--