I am trying the below code in JMeter BeanShell
I need to compare the value of OldT
with ${so_tid_1}
which is an exact string and not a variable
String OldT = vars.get("OldT");
if (OldT.equals("${so_tid_1}")){
vars.put("OldT","ABCD");
}
I have observed that the if condition is not executed even when the value of OldT is received as ${so_tid_1}
. But if I change the condition as if(OldT.equals("some string")
it works fine and I get the expected output.
Any thoughts on why it is not working?
Just do this:
String OldT = vars.get("OldT"); // I need to compare the value of OldT
// with ${so_tid_1} which is an exact
// string and not a variable
if (OldT.equals("\${so_tid_1}")){
vars.put("OldT","ABCD");
}
You need to escape $ sign.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With