Create a variable extractor

This tutorial describes in detail the various steps involved in creating a Variable Extractor. It explains in which context a Variable Extractor should be used and provides an actual example.

To ensure that this tutorial applies to your case, it is advised to first read and understand the data extraction method, as described in Choose a data extraction method<in_pdf_tuto>. For an overview of creating a Virtual User, see Design process<in_pdf_designing>.

Understand the problem

The contents of HTML pages generated by your application contain dynamic elements. Typical examples of dynamic content are elements such as HTTP request parameters or links with generated URLs. But in some situations these elements are neither parameters nor links, they are plain HTML elements belonging to the page. Nevertheless you might need to extract these dynamic elements to obtain more realistic scenarios and more thorough test results. You can look at the following excerpt from an HTTP response, containing the result of an account registration feature:

<HTML> 
   <BODY> 
      <H2>Create an account</H2> 
      <P> 
         <B>Error registering account:</B> 
         <I>The user name you have chosen is already in use.</I> 
      </P> 
      <P>The following suggestions are available:</P>
      <UL> 
         <LI>Suggestion 1: <I>WBrown</I> 
         <LI>Suggestion 2: <I>WilliamBrown_1</I> 
      </UL> 
      <P>Enter another user name and retry</P> 
      <FORM action="index.jsp" method="post"> 
         <INPUT type="text" name="username" /><BR/> 
         <INPUT type="submit" value="Send"> 
      </FORM> 
   </BODY> 
</HTML>

The HTML page contains text explaining that account registration has failed because the user name provided by the user already existed. The page then suggests alternative user names that the user could use. It finally provides an HTML form for the user to retry creating an account using a different user name, possibly one of the suggested alternatives. If you wanted to define a scenario where the Virtual User selects one of the suggested alternatives, for example the first one in the list for instance, you need to extract WBrown to re-inject it into the request that submits the form.

In this case, you are going to use a mechanism called the Variable Extractor which extracts arbitrary contents from an HTTP response and assigns the contents to a variable. The variable can then be used anywhere NeoLoad accepts variable values. The extracting mechanism and the way to use the extracted value are the subjects this tutorial mainly addresses.