Extract Similar Drop-Down Lists From a Single Page Using Neoload

Challenge: Your scripting path brings you to a page that has multiple drop-down lists with similar source structure. You need to randomly select a value from both lists what will be used later in the script.

If you view the source of this page you will see that it has 2 drop down lists. The values in each are structured in the following way: <option value=”ABCD”>ABCD</option>.

Drop Down 1 - City

Drop Down 2 - Zip Codes

Here is an example of a generic variable extractor -

If you create a generic variable extractor to capture the list values you will get a mix of both city and zip code values as shown below. You should also note that the blank value ‘—’ is included in the list. Using the blank value later in your script may cause the script to fail.

In Neoload you can use regular expressions to create complex variable extraction or you can use the GUI. For the below example I used the GUI to create a variable extractor that will only save list items if they are numeric. For our example this extractor saves all zip codes on our page.

The center highlighted area is where you configure the matching patterns. The results are shown in the highlighted section at the bottom of the image.

I also created an extractor to save only the list of cities as shown below.  This one has a few added matching patterns to account for city names that may or may not include spaces.

Its a good idea to see if your patterns capture all the values you are expecting. I like to run a single ‘check virtual user’ to ensure this is working as shown below. You can see that when you extract all values Neoload automatically generated a ‘variablename_rand’ variable that contains a randomly selected value as well as a ‘variablename_matchNr’ variable that contains a count of instances extracted.

Now lets set the variable extractor to only select a single value at random. This method stores only a single variable, instead of a list of variables, and allows you to use the original name later instead of variablename_12 for the 12th value saved.

Here is the resulting  ’check virtual user’. The variable extract_zipcode contains only a valid random zip code and extract_city contains only a valid random city name. Depending on the run the generic_extraction may either contain a ‘—’, a zip code, or a city name.

To use these variables later in our script we can now just substitute a ${extract_city} or a ${extract_zipcode} wher the original static value exists.

One thought on “Extract Similar Drop-Down Lists From a Single Page Using Neoload

  1. Pingback: Neoload – Updating Extracted Variables Inside Loops | Sandbreak Digital Solutions

Leave a Reply