Consider recording the following scenario:

  • User logs in and navigates to the Contacts page
  • The page has a table of multiple contacts, and each contact has an edit link.
  • The user clicks on the first edit link, edits the contact info
  • The user logs out

However, during the test, it is required that each VU clicks on every available edit link in the contacts table. The following section describes the steps to achieve this load test scenario.

The first step is to create an extractor from the Contacts page that extracts all the edit links.

  1. Create an extractor that extracts the first edit link.

    Example: In this case, we'll use a regular expression extractor that with the following definition: <a rel="edit_contact" href="(.*?)"

  2. Set the Occurrence type property to Multiple

Verifying

When clicking Verify Extractor button of an extractor with the Occurrence type property set to Multiple, the verify dialog will display all recorded occurrences.

A multiple occurrence extractor is unlike the constant and random occurrence extractor. During the extractor's response, an array of all occurrences are extracted. When applying the extractor as a parameter, it follows the following behavior: 

  • If the extractor pattern is not found in the response, nothing is returned
  • If the extractor is used as a parameter (not inside a loop), the next value in the array is returned.
  • If the extractor is used inside a looping object (such as a Loop or Do...While), it returns the array's value at the index equal to the loop iteration. If the iteration is greater than the elements in the array, then the first item is returned.

It may also be necessary to return the occurrence number or the number of occurrences. In these situations, you may choose the instance property in the variable picker.

The variable picker will have 3 options below the extractor:

  • Occurrence - returns the occurrence of the extractor
  • OccurrenceZeroBased - returns the occurrence of the extractor that starts from 0 instead of 1.
  • Count - return the number of total occurrences found

The next step would be to emulate a click through every link that was extracted above.

  • Create a loop around the Edit Contact transaction
  • Set the Number of repeats property to {{edit_links.Count }} to loop through all the extracted edit contact links

  • Make the necessary parameterizations inside the requests inside the Edit Contact transaction to emulate editing a different contact on every iteration of the loop. 
  • No labels