Creating GUIDs in Loadster scripts

Loadster is a simple-to-use, cloud based load testing platform, with an intuitive UI for building and running test scripts.

You can define steps, each of which is a call to your service, and check the responses for correctness. Several steps can be combined to form a script. Values can be extracted from responses for use as variables in later steps.

But what if you want to generate a value which isn’t present in a response? There are some built in functions to create random numbers, but no obvious way to create GUIDs, for example.

You can use a Code Block to run Javascript, but there’s no way to store the results of the function in a variable for later use.

However, you can use the “Capture with Javascript” element with an initial step, and instead of processing the response, just run your Javascript function:

This generates a GUID, and sets the transaction_guid variable with the result.

Then you can use the variable in subsequent steps as you would any other variable in Loadster scripts:

You do need to have an initial step in the script which allows you to attach the Javascript function – though you could make that a very light weight call to another service if you didn’t want to hit the main service under test twice.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.