I Need to get to variable field from http request which is called Name. If anyone could give my examples how can I get other fields such as : Path, Server name or IP using beanshell?
Thank you in advance
Use following code lines to get the required values:
String name = sampler.getName(); // get parent sampler name
String path = sampler.getUrl().getPath(); // get path
String url = sampler.getUrl().getHost(); // get IP or hostname
you can also store values into JMeter Variables if required like
vars.put("name", name);
See How to Use BeanShell: JMeter's Favorite Built-in Component guide for comprehensive information on using Beanshell scripting in your JMeter test.
Below code can give you the HTTP Request Name field value
ctx.getCurrentSampler().getName()
I think you can do it without beanshell. Just use inside your sampler ${__samplerName()}
https://jmeter.apache.org/usermanual/functions.html#__samplerName