JMeter-使用其他BeanShell预处理器/后处理器中的变量吗? [英] JMeter - Using Variables from other BeanShell Pre/Post-Processors?

查看:231
本文介绍了JMeter-使用其他BeanShell预处理器/后处理器中的变量吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以将一个BeanShell前后处理器中的变量引用到另一个BeanShell处理器(它们在同一线程组中)?

Is there a way to reference a variable from one BeanShell Pre/Post-Processor to another BeanShell Processor (they are within the same Thread Group)?

如果我在HTTP请求下的BeanShell PreProcessor中创建一个String变量,那么我可以在同一HTTP请求下的BeanShell PostProcessor内使用或引用该变量吗??

If I create a String variable inside a BeanShell PreProcessor under an HTTP Request, can I then use or reference that variable inside a BeanShell PostProcessor under that same HTTP Request..?

我尝试通过以下方式访问此变量:

    + HTTP请求
       + BeanShell PreProcessor:

I tried Accessing this variable in the following ways:

    + HTTP Request
       + BeanShell PreProcessor:

String preProcessor1_MYID = "Value_1";

       + BeanShell PostProcessor:

       + BeanShell PostProcessor:

String postProcessor1_MYID = "Value_2";
//Try #1:
String tmp_preProcessor1_MYID = preProcessor1_MYID;
//Try #2:
String tmp_preProcessor1_MYID = ${preProcessor1_MYID};
//Try #3:
String tmp_preProcessor1_MYID = ${__V(preProcessor1_MYID)};
//Try #4:
String tmp_preProcessor1_MYID = vars.get("preProcessor1_MYID");


有没有像$ {__ V()}或vars.get()这样的函数,我错过了我应该使用的函数?我还想知道是否需要一个User Defined Variables对象才能在BeanShell Pre/PostProcessors之间共享此变量,但是我不确定.我还阅读了有关$ {__ BeanShell()}函数的信息,但我也不认为那是我要找的...有什么想法吗?我以为这应该可行,但是希望我不需要添加任何类似User-Defined Vars对象的东西.


Is there a different function like ${__V()} or vars.get(), that I'm missing that I'm supposed to be using? I was also wondering if I needed a User Defined Variables object in order to share this variable between BeanShell Pre/PostProcessors but I wasn't sure. I also read about the ${__BeanShell()} function, but didn't think that was what I was looking for either... Any ideas? I would assume this should be possible, but was hoping I didn't need to add anything like the User-Defined Vars object.

任何想法或建议将不胜感激!

Any thoughts or suggestion would be greatly appreciated!

在此先感谢,
马特

Thanks in Advance,
Matt

推荐答案

如果以后需要在其他元素中使用该值,则

If you need to use the value in other elements later,

将其存储在一个可变的

vars.put("myvar", "value");

现在您可以使用

${myvar}

或在beanshell中

or in beanshell

vars.get("myvar").

这篇关于JMeter-使用其他BeanShell预处理器/后处理器中的变量吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆