1

I am making scripts using JMeter to perform some tasks in which I want to access first request's response in the second request as a value parameter value using XPath extractor.

For Ex.

Here is my response of the first request in XML format:

<a>
  <b>
    <c>

       <my_details>
          <first_name>A</first_name>
          <middle_name>B</middle_name>
          <last_name>C</last_name>
       </my_details>

    </c>
  </b>
</a>

Now, I want to use first name and last name in the second request's value. For that, I am using XPath extractor to get values from the response as given below:

enter image description here

But I got the response like:

        JMeterVariables:
        **full_name=A
        full_name_1=A**
        ...
        ...
        __jm__Thread Group__idx=0
        __jmeter.USER_TOKEN__=Thread Group 1-1

So, my question is, how can I get the full name using single XPath extractor?

Jui Shah
  • 108
  • 1
  • 10

2 Answers2

0

Try to extract "first_name" and last "last_name" separately using XPath extractor , Then use Beanshell post-processor to create Jmeter variable for fullname , Like

vars.put("full_name",vars.get("FIRST NAME JMETER VARIABLE")+" "+vars.get("LAST NAME JMETER VARIABLE"));

vishal Bagi
  • 21
  • 1
  • 2
0

I was able to achieve the desired result using the concat() function (https://www.w3.org/2005/xpath-functions/).

I utilized XPath2 Extractor with Xpath query set to:

concat(//my_details/first_name, " ", //my_details/last_name)

XPath2 Extractor

This leads to output variable being assigned the value "A C": enter image description here

Please, note that it is currently advised to use XPath2 Extractor (https://jmeter.apache.org/usermanual/component_reference.html#XPath_Extractor):

enter image description here

George Rylkov
  • 614
  • 5
  • 8