How to use Jmeter built in function within Preprocessor

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use Jmeter built in function within Preprocessor

UserJMeter999
 When i try to use this function in JSR Preprocessor
${__FileToString(C:\Users\xyz\Desktop\Test.txt,,MESSAGE)}

getting below error
2018-06-28 14:38:19,325 ERROR o.a.j.m.JSR223PreProcessor: Problem in JSR223
script, JSR223 PreProcessor -
in inline evaluation of: ``{"account": {"accountType": "INDIV"," . . . '' at

line number 1



But in if we see MESSAGE in post debug processor i see value is being
assigned to MESSAGE variable as expected.
Reply | Threaded
Open this post in threaded view
|

Re: How to use Jmeter built in function within Preprocessor

Felix Schumacher


Am 28.06.2018 um 21:56 schrieb JMeter User:
>   When i try to use this function in JSR Preprocessor
> ${__FileToString(C:\Users\xyz\Desktop\Test.txt,,MESSAGE)}
>
> getting below error
> 2018-06-28 14:38:19,325 ERROR o.a.j.m.JSR223PreProcessor: Problem in JSR223
> script, JSR223 PreProcessor -
> in inline evaluation of: ``{"account": {"accountType": "INDIV"," . . . '' at
>
> line number 1

The ${...} will be replaced by JMeter before the JSR Preprocessor gets
the text (code).
Therefore it will get the content of the file, which seems to be a JSON
text, that will not be valid code for most of the JSR223 languages.

>
>
>
> But in if we see MESSAGE in post debug processor i see value is being
> assigned to MESSAGE variable as expected.

That is expected, as the ${...} got evaluated correctly and thus the
variable set.

It is probably easier to remove the JSR223 Preprocessor and place the
${...} directly where you use the variable MESSAGE the first time. If
you use it again later in the test plan, you can reuse the variable
instead of re-reading it from the file.

Regards,
 ¬†Felix

>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]