Reputation: 330
I'm new to JMeter BeanShell PreProcessor function.
For a test I'm trying to print sample URL address. From the tutorial I have the follownig code:
org.apache.jmeter.samplers.SampleResult;
String currentURL = SampleResult.getUrlAsString();
print(currentURL)
But I get error "Attempt to resolve method: getUrlAsString() on undefined variable", how to define this variable first?
Upvotes: 2
Views: 456
Reputation: 168002
If you are using a PreProcessor it means that you don't have any SampleResult as sampler has not been yet executed. So you need to use sampler
shorthand which is resolved into HTTPSamplerProxy like:
sampler.getUrl() as String
Demo:
More information: Apache Groovy - Why and How You Should Use It
Upvotes: 0
Reputation: 705
This means the SampleResult does not exist.
You need to use prev as per this doc:
Which references this javadoc:
Upvotes: 1