Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
386 views
in Technique[技术] by (71.8m points)

correlation - Jmeter - Calling javascript using JSR223 Post processor

I capture 6 elements using a regular expression. say

Variable : UserDetails
Regular Expression : loadHeadWorkFlow('(.+?)','(.+?)','(.+?)','(.+?)','(.+?)','(.+?)','/I
Template : $1$$2$$3$$4$$5$$6$

Now I could access these values via UserDetails_g1, UserDetails_g2.....UserDetails_g6

Next, these 6 values need to be encrypted using a javascript file. The file contains the logic.

How should my code be using JSR223 post processor?

The steps that I followed:

1.

load('Encryption.js');

   var result = encrypt("${UserDetails_g1}","password");
   log.info("encrypted value is "+result);
   vars.put("LoginDataString",result);

   var result1 = encrypt("${UserDetails_g2}","password1");
   vars.put("UserId",result1);

   var result2 = encrypt("${UserDetails_g3}","password2");
   vars.put("RoleId",result2);

First value is encrypted correctly. But the other values aren't correct. If I add individual post processors for every variable. All the encrypted values show correctly.

Is there a way where I could use a single post processor to perform all the 6 encryptions. Thanks in advance

Regards, Ajith

question from:https://stackoverflow.com/questions/65870524/jmeter-calling-javascript-using-jsr223-post-processor

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Use vars instead of ${} syntax

 var result = encrypt(vars.get("UserDetails_g1"),"password");
 log.info("encrypted value is "+result);
 vars.put("LoginDataString",result);

 var result1 = encrypt(vars.get("UserDetails_g2"),"password1");
 vars.put("UserId",result1);

 var result2 = encrypt(vars.get("UserDetails_g3"),"password2");
 vars.put("RoleId",result2);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...