Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am storing a variable using vars.put() in JMeter and when i try to use _matchNr, it is returning null. Upon logging the variable in the same file where i am calling _matchNr, it showed correct output (which should meant that variable is not null in itself). So is there a reason, why matchNr is giving null output?
log.info("this is transaction" + "${transactionAmountResp}");
log.info("this is transaction_match" +
vars.get("transactionAmountResp_matchNr"));
int number = Integer.parseInt("${transactionAmountResp_matchNr}");
I am using this in Beanshell Assertion to check whether transactionAmountResp matches with some other already set variable.
You shouldn't use ${}
syntax inside Beanshell/JSR233 script, use vars.get
log.info("this is transaction" + vars.get("transactionAmountResp"));
int number = Integer.parseInt(vars.get("transactionAmountResp_matchNr"));
–
–
–
–
Don't use Beanshell, since JMeter 3.1 you should be using JSR223 Elements and Groovy language for scripting
Don't inline JMeter Functions or Variables into scripts, use code-based equivalents instead
You can use normal Response Assertion for comparing 2 JMeter Variables:
You can double check JMeter Variables or Properties values using Debug Sampler and View Results Tree listener combination, if the variable is not there it's absolutely expected that you will get null
trying to read its value
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.