Configuring File Downloads - Web Performance
Menu

Configuring File Downloads

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

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:

  1. Locate the source for these values
  2. Configure an extractor to put that value into the user state
  3. Configure the URL to use the extracted values from the user state

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

Example of source of dynamic parts of file URL

With the source located, the next step is to configure an extractor:

  1. Open the Actors view
  2. Select the Extractors tab
  3. Press the Add Extractor (+) button

In this case, we will use a Regular Expressionextractor with two capture groups.

Extractor configuration using a regular expression

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:

  1. Select the URL to be configured in the testcase. This should be the page or transaction that returns the downloaded file
  2. Open the Headers view
  3. Press the Edit the Start Line button next to the URL/Start Line
  4. Select the second path segment (e5fb4c74-31ef-4f5b-b920-0a28016c5969)
  5. Select Use User Variable and enter the name of the variable used in the extractor (e.g. file_path)
  6. repeat for the third path segment (RecordedDocument.pdf)
Configuration of two dynamic path segments in URL

Configuration of two dynamic path segments in URL

That’s it! The testcase will now download the correct file.

Chris, Chief Engineer

Add Your Comment

You must be logged in to post a comment.

Resources

Copyright © 2024 Web Performance, Inc.

A Durham web design company

×

(1) 919-845-7601 9AM-5PM EST

Just complete this form and we will get back to you as soon as possible with a quote. Please note: Technical support questions should be posted to our online support system.

About You
How Many Concurrent Users