Search code examples
jmeterjsr223

Print variable to CONSOLE


I'm trying to print variable to CONSOLE.

I need to print only using IF condition to check variable is empty or not.

I tried below code on JSR223 but not working

if (${__javaScript(vars.get("err") != null)})
{
    ${__logn(Complete,OUT)}
    } else {
        ${__logn(ErrorMessage=${err},OUT)}
        }```

Solution

  • Don't use ${} syntax in JSR223, I think you mean to do the following

    if (vars.get("err") == null) {
        OUT.println("Complete");
    } else {
        OUT.println("ErrorMessage=" + vars.get("err"));
    }