Page tree
Skip to end of metadata
Go to start of metadata

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

e.q. http://www.google.com.hk/search?hl=zh-CN&source=hp&q=helloworld&meta=&rlz=1R2GGLR_zh-TWDE349&aq=f&aqi=g10&aql=&oq=&gs_rfai=

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)

  • No labels

5 Comments

  1. Are the values file automatically transfered to EEM Repository during upload?

  2. Yes, all files in the script folder are automatically transferred to the repository, including such variable files.

  3. 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.

  4. Yes, this works. We actually use this feature for some generic example scripts.

  5. 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.