At the same time scripting languages play very important role in load testing. Some tools can pre-compile entire test into a script, so that it can be executed as a stand-along task. The ability to modify these scripts provides the most flexible way to create custom test scenarios. However such approach requires significant programming background for the test engineers. That is why it is usually preferable to remain on a higher level and treat each test profile as a sequence of HTTP requests.
To simulate a new user session correctly it is not sufficient to replay the recorded session as is. To handle dynamic content of your web site you need to parameterize the initially recorded requests. This may be required for two reasons.
- You may want to specify different user input parameters (such as name and password) for different users (more on that here). This is also called “data-driven testing”.
- You have to preserve the session integrity. For this reason you need to specify how to extract some values (such as jsessionID for Java, or __VIEWSTATE for ASP.NET applications) from server responses in order to reuse these values in the subsequent requests.
So, you need to have a way to insert dynamic values into HTTP requests. You can either extract these values from server responses, or read them from external sources (files or databases).
Each load testing tool has a number of functions that can accomplish these tasks. Usually these functions cover most common cases; however practice shows that to handle all possible situations we need to have some more general solution.
The most important thing is that from this code you can access the latest server response and all internal variables. The latter means that you can read and modify the values of these variables. So, you can use the script both to process the result of the previous request and to prepare values of parameters for the next one.
- Calculation of values for the parameters of requests inside user sessions.
- Extraction of values from server responses.
- Validation of server responses.