1
votes

I try to pass 2 variables to the BeanShell script of Jmeter but it fails with the error. However, if I pass a hardcoded string value, it works.

Beanshell assertion to compare variable AdID1 and MAdID1

String addrress1="${AdID1}"; 
String memberAddress1="${MAdID1}"; 

Failure1 = !addrress1.equals(memberAddress1);

if (Failure1) {
  FailureMessage = "Variables are not equal. Expected \"" + addrress1 + "\" , actual:\"" + memberAddress1 + "\"";
}


if(addrress1.equals(memberAddress1)) {
    log.info("Matched"); 

Error:BeanShellAssertion: org.apache.jorphan.util.JMeterException: Error invoking bsh method

2

2 Answers

0
votes

Don't inline JMeter Functions or Variables into scripts.

Try to use the JMeter variables in your scripts like this:

String addrress1= vars.get("AdID1");
String memberAddress1= vars.get("MAdID1");

It is advised to use JSR223 Test Elements and Groovy Language rather using BeanShell.

0
votes

It is recommended to avoid scripting and use built-in JMeter Test Elements or Functions or Plugins and avoid scripting where possible so I would suggest going for Response Assertion.

The relevant configuration would be:

enter image description here

With regards to your script - it appears it's missing closing }.