Substitution with dynamic values read from a textfile
You want to substitute http query parameters with dynamic values from a list of value in a file or in script configuration during runtime. For example you want to change following query parameter during runtime
Starting from EEM SP22 you can specify the dynamic parameter by a file or a list in script configuration.
- Right click and choose "Insert Message"
- Choose options like following, for following case we read values from values.txt and assign it to variable {query}
- Specify the variable in http requests. You can reference the variable by {}
- Specify candidate values in values.txt. Goto script folder. Create values.txt with line separated values; for example:
Usher
Bach
Müller
Bush
- Test the script in EEM Editor. The Image shows that the variable is used in the query
Alternative
- You can also specify list of variables by 'AssignFromList' command (In this case you don't need to create values.txt)
5 Comments
Bernd Zucker
Are the values file automatically transfered to EEM Repository during upload?
Jens Claussen
Yes, all files in the script folder are automatically transferred to the repository, including such variable files.
Former Member
Can I use a variable for the host name? We have a case where the same steps will apply but for multiple hosts.
I could create multiple scripts, but ideally we want one script with only host name being different.
Jens Claussen
Yes, this works. We actually use this feature for some generic example scripts.
Former Member
Thanks Jens, however can you please explain how do you make sure all variables are being used or just "ramdom" from list?
Here is our scenario, we will have http script where the URL will be with different hosts, as well as these scripts will be running from multiple robots.
While you confirm variable will work to replace host name, we want to make sure we are running this script for all hosts we specify.
Any help or a link to one would highly be appreciated.
Thanks.