0
votes

I am extracting a variable from the HTTPReponse body which contains a string containing special characters. When I try to access the variablein the script, I am getting the following error. Is there a way to access these vars while preserving the special characters?

jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval In file: inline evaluation of: `` token += "" + auQV8OGH47fz50YFm9rS/dQjTcUuGi55ryzC7S3YInNcaciCVR3/frSHwv8CE/mJD . . . '' Encountered "oSQ" at line 1, column 269.

1

1 Answers

1
votes

Most probably you are accessing JMeter Variable in your script body as ${variable_name_here} which is not very recommended.

Beanshell should handle JMeter Variables without any issues given you access them via vars shorthand (or through "Parameters" section)

Given you have a JMeter Variable ${foo} the correct ways of accessing its value will be:

  1. Using vars shorthand:

    String foo = vars.get("foo");
    
  2. Using "Parameters" section (assumes you have ${foo} there)

    • String foo = Parameters;
    • String foo = bsh.args[0];

Demo:

Beanshell different ways of accessing JMeter Variables

Other troubleshooting techniques:

  • You can add debug() command to the beginning of your script so debugging output will be printed into JMeter console window
  • You can put your Beanshell code inside the try block like:

    try { //your code here } catch (Throwable ex) { log.error("Beanshell failure", ex); throw ex; }

See How to Use BeanShell: JMeter's Favorite Built-in Component article for more information on using Beanshell scripting in JMeter tests