Issue
I am getting an issue in one of the webdriver samplers - "sampleResult.setFailure - Response message:javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: org.apache.jmeter.samplers.SampleResult.setFailure() is applicable for argument types: (Boolean) values: [true]"
Following is the groovy code snippet I have used for the jp@gc webdriver sampler. WDS.log.info is working as expected. But I can't make the sampler fail if the condition fails, due to the above error. Can you please help me identify the issue?
var compareWord = tempXpath.getText();
if (compareWord.contains("$value")) {
WDS.log.info("The value is as expected");
}
else{
WDS.sampleResult.setFailure(true);
WDS.log.info("The field not matching for: " + "$value");
}
Solution
I don't know where you got information regarding existence of SampleResult.setFailure()
function, my expectation is that from generative AI.
If you look into JavaDoc you will see that the function doesn't exist and if you look into JMeter source code you will see that it has never existed.
Correct function is SampleResult.setSuccessful() so instead of this one:
WDS.sampleResult.setFailure(true);
you should use something like:
WDS.sampleResult.setSuccessful(false);
More information: Top 8 JMeter Java Classes You Should Be Using with Groovy
Answered By - Dmitri T
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.