Skip to content

XPath2 Variable Extractor

XPath2 Variable Extractors lets you extract variables from HTML/XML responses using XPath2 queries.

Extracting variables from HTTP response helps you make your Virtual User have a dynamic behavior. Extracted variables can be injected in Logic Actions or HTTP Request Actions.

Header XPath2 Extractor

The first line displays the extracted variable name. This field is mandatory if you want to inject what you extract. The second line contains tab headers to access:

  • Configuration, for more specific needs,
  • Check, to validate the result of your XPath2 against an HTTP response.


The response selector, on the right, lets you choose which HTTP response is used for configuring and checking the XPath2 Action. So if neither recorded responses nor Validate VU responses are available, you have to configure the XPath2 Action blindly.


XPath2 Extractor configuration

To configure a XPath2 extractor, the procedure is as follows:

  1. Fill the XPath 2.0 query field with a proper XPath expression,
  2. Select the Match number if your expression yields more than one result,
  3. Add a namespace. In our example with no prefix (as seen on line 21 in the HTML). But you will have to adapt this to your use case.


You can use third party tools like XPather to accelerate the design of your XPath expression. Just copy and paste the content of the response displayed on this page.


XPath2 Extractor check

To **check the result of a XPath2 ** action just click on the Check tab.

The check process is automatically launched when this tab is opened. It can also be manually started using the Refresh button.

A table contains the extracted values :

Column name Description
Extracted variable name The name of the extracted variable. A single XPath2 Action can lead to multiple extracted variables. More information below.
Extracted variable value The value of the extracted variable.


Multiple variables can be generated by a single XPath2 Action.

E.g. using the following HTML body :

<form method="post" action="/actions/Catalog.action">
    <input name="keyword" type="text" />
    <input name="searchProducts" type="submit" value="Search" />
    <input type="hidden" name="_sourcePage" value="8UhFy3GTVvJLzGIdfPyNqtoclan" />
<form method="post" action="/actions/Account.action">
    Please enter your username and password.
    Username:<input name="username" type="text" />
    Password:<input name="password" type="password" />
    <input name="signon" type="submit" value="Login" />
    <input type="hidden" name="_sourcePage" value="o_adZEJ7UO8IhGgRmltu2Ra6rSr" />
For an extractor named sourcePage with the XPath2 path value //input[@name='_sourcePage']/@value and a Select Nth match number:

  • sourcePage : the base variable, it contains the extracted value (or the default value), e.g. 8UhFy3GTVvJLzGIdfPyNqtoclan

With an All match number, multiple variables are generated :

  • sourcePage : the default value as specified on the advanced tab,
  • sourcePage_N : the Nth value extracted,
  • sourcePage_matchNr : the number of values extracted, e.g. 2.


An extracted variable without name cannot be used for value injection.