Home > other >  I am unable to ignore the failed response code/message using BeanShell PostProcessor in JMeter
I am unable to ignore the failed response code/message using BeanShell PostProcessor in JMeter

Time:12-08

I am having multiple sampler in which i am trying to setup a script which ignores an error message or any response code and tryinh to make a sampler as "pass".

but i am unable to do that.

Below is my configuration.

JMeter Configuration for BeanShell Post Processor

You can see that in an benshell postprocessor i tries to ignore 3 responses (non http , 504 and 401)

But in the "View Result Tree" listner i am still getting ignored status code as failed.

Response

You can see in an image that 401 error code request is failed.

Can you please let me know what i am doing wrong here.

I also tried jsr223 response assertion,but not able to get expected output.

I also checked my logs as well.

CodePudding user response:

There are multiple problems with your script:

  1. You're using == instead of equals() which compares references and not instances so it might be the case the code is not executed at all
  2. Setting response code to 200 is not sufficient to suppress the failure, you need to additionally invoke prev.setSuccessful(true) function
  3. Since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for scripting because Groovy performance is much better comparing to Beanshell
  4. You might want to use switch statement instead of multiple if/else clauses

CodePudding user response:

Hello why you use JMeter do you know K6 : https://k6.io/ It's better than JMeter

  • Related