Reputation: 11
Consider we have a URL path as below, https://www.google.co.in/search?q=${query_string) where query_string is a variable passed from a csv file.
Now in Jmeter bean shell pre/post processor i need the original URL before assigning the variable value, ie, https://www.google.co.in/search?q=${query_string).
Do we have any way to retrieve this?
Upvotes: 1
Views: 1312
Reputation: 58772
Save your url in a variable myUrl
https://www.google.co.in/search?q=${query_string}
When you use the url execute __V function
${__V(myUrl)}
This will return https://www.google.co.in/search?q=myString
When you need the original URL use
${myUrl}
Upvotes: 0
Reputation: 168082
I wouldn't recommend using Beanshell as it has known performance problems so consider switching to JSR223 Test Elements and Groovy language.
The relevant groovy code you can use in JSR223 PreProcessor or JSR223 PostProcessor would be something like:
def url = sampler.getUrl();
def protocol = url.getProtocol()
def host = url.getHost()
def path = url.getPath()
log.info('Full URL: ' + url.toString())
log.info('URL you want: ' + protocol + '://' + host + path)
Demo:
See Apache Groovy - Why and How You Should Use It article for more details about Groovy scripting in JMeter tests.
Upvotes: 2