Skip to content

File Downloads: Handling Dynamic URLs

In most cases, Load Tester handles file downloads during a test case automatically. Fundamentally, there's no difference between downloading a spreadsheet or an image on the page.

But in some cases, Load Tester does not automatically handle dynamic URLs used in certain situations. Most commonly, these are cases where:

  • The file is being generated on-demand
  • The file is assigned a unique identifier that is part of the URL path (not a query parameter)
  • There's no unique field name or query parameter name Load Tester can use to locate the dynamic value

Example of problematic dynamic file URL:

https://example.com/docs/e5fb4c74-31ef-4f5b-b920-0a28016c5969/RecordedDocument.pdf

In this URL, two path segments are dynamic:

  • e5fb4c74-31ef-4f5b-b920-0a28016c5969 (unique file ID)
  • RecordedDocument.pdf (filename)

Because there's no query parameter name (like ?fileId=...), Load Tester doesn't automatically correlate these values. Instead, it requests the same URL each time, which fails when the file ID changes between sessions.

Customizing for Dynamic File Downloads (3 Steps)

  1. Locate the source for the dynamic values
  2. Configure an extractor to put those values into user state
  3. Configure the URL to use the extracted values

Step 1: Locate the Source of Dynamic Values

The source will typically be in the previous web page. For our example, the source might look like this in the HTML response:

<a href="/docs/e5fb4c74-31ef-4f5b-b920-0a28016c5969/RecordedDocument.pdf">Download</a>

Find this:

  1. Select the transaction before the file download in Test Case Editor
  2. Open Response Content view: Window → Show View → Response Content
  3. Search for the dynamic value (use the Search tab)
  4. Note the pattern around the value (the href attribute in this case)

Step 2: Configure Extractor to Capture Values

  1. Open Actors View: Window → Show View → Actors
  2. Select: Extractors tab
  3. Click: Add Extractor (+) button

Configure the extractor:

  • Extractor Type: Regular Expression
  • Applied To: Select the transaction containing the source (previous page)
  • Pattern: /docs/([\w\-]*)/([\w\.]*)
  • First capture group: ([\w\-]*) matches the file ID
  • Second capture group: ([\w\.]*) matches the filename
  • Variable Names: file_path file_name (space-separated, one name per capture group)
  • Instance: 1 (extract first match)

Verify extraction: The Value selected for extraction field at the bottom of the dialog should show the values extracted from the recorded page. If it's blank, your pattern doesn't match. Adjust the regular expression.

Regular Expressions

Regular expressions are a complex topic outside the scope of this guide. There are many great sources available that cover regex in detail. The key is to create a pattern that matches the dynamic parts of the URL and uses capture groups (...) to extract specific values.

Step 3: Configure URL to Use Extracted Values

With the extractor configured, the final step is to configure the download URL to use these values during replay.

Edit the Request-Line (URL path):

  1. Select the file download transaction in Test Case Editor (the one with the dynamic URL)
  2. Open Headers View: Window → Show View → Headers
  3. Click: Edit the Start Line button (next to the URL/Start Line)

Configure each dynamic path segment:

  1. Select the second path segment (the file ID: e5fb4c74-31ef-4f5b-b920-0a28016c5969)
  2. Choose: Use User Variable
  3. Enter variable name: file_path (the variable name from the extractor)
  4. Repeat for the third path segment (filename: RecordedDocument.pdf)
  5. Choose: Use User Variable
  6. Enter variable name: file_name
  7. Click: OK

That's it! The test case will now download the correct file during each replay, using the values extracted from the previous page.

Troubleshooting

Dynamic File Download Gets 404 Error

Symptom: File download transaction fails with 404 Not Found during replay.

Likely causes:

  1. Extractor not configured to capture dynamic URL values
  2. URL not configured to use extracted variables
  3. Extractor pattern doesn't match the source content

Solution:

  • Check extractor: Actors View → Extractors tab → Verify extractor shows "Value selected for extraction" (if blank, pattern doesn't match)
  • Check URL configuration: Headers View → Edit Start Line → Verify path segments use correct user variables
  • Test extraction manually: Run a replay and check Fields View to see if user variables are populated