Pravesh wrote:
Hi Team,
Any sample where we can extract value from 1st response and put into
another request with beanshell.
I dont want to use regex.
I want to take session value from response
image.png
store as variable and send to 2nd variable with help of beanshell
--
Regards,
Pravesh prajapati.
Mob:-9702600170
You're absolutely right <https://stackoverflow.com/a/1732454/2897748>
about your unwillingness to use regular expressions for getting value
from HTML, you should use CSS Selector Extractor
<https://www.blazemeter.com/blog/cssjquery-extractor>instead.
With regards to Beanshell:
1. Since JMeter 3.1 it's recommended to use JSR223 Sampler and Groovy
language
<https://jmeter.apache.org/usermanual/best-practices.html#bsh_scripting>
for scripting
2. Inside Beanshell and/or Groovy you will still need to use regular
expressions or functions from XPath/JSoup and it's better to use
If you're still interested in extracting the value using Beanshell I can
give some example code, it would be something like
String response =prev.getResponseDataAsString();
Pattern p =Pattern.compile("name=\"userSession\"value=\"(.+?)\"");
Matcher m =p.matcher(response);
if (m.find()) {
vars.put("userSession",m.group(1));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@jmeter.apache.org
For additional commands, e-mail: user-h...@jmeter.apache.org