You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by sebb <se...@gmail.com> on 2008/08/11 13:52:55 UTC
Re: Scritping a BeanShell PreProcessor
On 30/07/2008, rmiller <ro...@cobancorporation.com> wrote:
>
> I'm attempting to build a search query in a BeanShell Preprocessor. I get a
> search term from a CVS Dataset Config and store in the variable queryTerm.
> Then in the preprocessor I use the following code to build the query and
> store in a user defined variable:
>
> String _query = "%5Bfullname%5D%20contains%20" + ${queryTerm} + "%5F";
Try removing the String variable type.
> vars.put("staffQuery", _query);
>
> Here's the error from the log when I run this:
>
> 2008/07/30 08:41:00 ERROR - jmeter.util.BeanShellInterpreter: Error invoking
> bsh method: eval Sourced file: inline evaluation of: ``String _query =
> "%5Bfullname%5D%20contains%20" + ${queryTerm} + "%5E"; ;'' : Typed variable
> declaration : Attempt to access property on undefined variable or class name
This means that the queryTerm variable is not defined at the time the
script was processed.
> I've also tried vars.get("${queryTerm}") and vars.get("queryTerm") but it
> just returns a null value.
>
> How do I access the query term in the preprocessor?
${queryTerm} - will be replaced by the value of the variable before
BeanShell sees the script
or
vars.get("queryTerm") - allows BeanShell to look up the variable itself.
Why not just use
%5Bfullname%5D%20contains%20${queryTerm}%5F
in the sampler?
No need to use BeanShell just to build up a string.
>
> Thanks,
> Ron
>
> --
> View this message in context: http://www.nabble.com/Scritping-a-BeanShell-PreProcessor-tp18724200p18724200.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org