How to verify if response A or B is present in response text in jmeter using beanshell script assertion
Beanshell Assertion provides the following pre-defined variables:
ResponseData
- byte array, contains parent sampler responseFailure
- boolean, indicates whether assertion (and the sampler(s) in scope) is/are successful or notFailureMessage
- a String which can be used to provide a custom error messageExample code which checks if response contains A
and if doesn't - the sampler gets failed.
String response = new String(ResponseData);
Failure = !response.contains("A");
FailureMessage = "Response didn't contain A";
More information: How to Use JMeter Assertions in Three Easy Steps