In most cases Load Tester handles a file download during a testcase automatically. Fundamentally, there is no difference between downloading a spreadsheet or an image on the page. But in some cases, Load Tester does not automatically handle the dynamic URLs used in certain situations. Most commonly, these are cases where the file is being generated on-demand and is assigned a unique identifier that is part of the URL path, rather than a query parameter. In these cases, because there is no unique identifier that can be used to locate the value (i.e. a form field name or query parameter name), Load Tester does not automatically configure the testcase to use a different URL for each pass through the testcase. Instead, it asks for the same URL each time. Here is an example:
example of dynamic file URL
In the above example, two parts of the URL (called path segments) are dynamic: “e5fb4c74-31ef-4f5b-b920-0a28016c5969” and “RecordedDocument.pdf”.
Customizing a testcase to handle this situation can be done in three easy steps:
The source will typically be in the previous web page. In our example, it looks like this:
Example of source of dynamic parts of file URL
With the source located, the next step is to configure an extractor:
In this case, we will use a Regular Expressionextractor with two capture groups.
Extractor configuration using a regular expression
The expression in this case is
“/docs/([\w\-]*)/([\w\.]*)”
to match “e5fb4c74-31ef-4f5b-b920-0a28016c5969” and “RecordedDocument.pdf” respectively.
When multiple capture groups appear in the regular expression, then multiple variable names must also be supplied so the extractor knows where to store the values in the User State. In this case, I used “file_path” and “file_name”. If the extractor is configured correctly, the Value selected for extraction field, at the bottom of the dialog, will show the values extracted from the page (as recorded).
Regular expressions are a complex topic that are outside of the scope of this article. There are a number of great sources available that cover RegEx in great detail.
With the extractor complete, the final step is to configure the URL to use these values during the replay. This can be done by editing the Request-Line:
Configuration of two dynamic path segments in URL
That’s it! The testcase will now download the correct file.
Chris, Chief Engineer