Re: Need to execute javascript using JMeter
Christof <[email protected]> Wed, 02 Apr 2025 15:10:17 +0000
| Newsgroups | gmane.comp.jakarta.jmeter.user |
|---|---|
| Message-ID | <[email protected]> |
------F495OS1J0NTDWAVCPGYB4FDBE6LDAY Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Abhitosh, groovy is one of the supported languages in jsr223 sampler=2E If your java= script 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=20 Christof Am 2=2E April 2025 14:49:15 UTC schrieb Abhitosh Patil <abhitosh=2Eqa@gmai= l=2Ecom>: >Initially I was using Java 17 but later switched to java 8 >Currently getting error like "javax=2Escript=2EscriptExecution: reference >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 JavaScrip= t >> 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 JMete= r >> 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 The l= atter >> option is better from performance perspective as Groovy scripts can be >> compiled and cached and it matters especially for "heavy" tasks like >> cryptography=2E More information: Apache Groovy: What Is Groovy Used Fo= r?< >> 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 to pa= ss >> 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? >> ------F495OS1J0NTDWAVCPGYB4FDBE6LDAY--