How to create unique variables?

You can follow these instructions to create any types of unique variables, as an example, if you want to create a unique email address in the format auto-random_number@mydomain.com, you can use one of the following 2 solutions:

Solution 1:

1. SET_VAR HALT Random Random "1234567890"

    • This step generates a random 5 digit number using digits 0 through 9 and assigns the result of it to variable called "random"

mceclip0.png

2. SET_VAR HALT STATIC email "auto-@random@mydomain.com"

    • This step uses the random variable created in step 1 to create the email format we are interested in and assigns the results to the variable "email"

mceclip1.png

 

Solution 2:

  1. Create a data template by going to Artifacts -> Data Templates
  2. Click on + New to create a new data template
  3. Give it a name (i.e. email_generator) and create a field maybe called "email" with the timestamp checked. This will append a unique timestamp at the end of the value each time the call to this data template field is made

mceclip2.png

  1. Save the data template and click DataSets to add data sets to this template
  2. A data set will be automatically generated. Change the data set name if you prefer and set and the value of the email field starting with "auto"
  3. Now, when you use this data template in your test case, it will append a unique timestamp at the end
  4. Use this data template in your FILL command as follows: FILL application_page.text.my_text ${email_generator.email}@mydomain.com

mceclip3.png

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

  • Avatar
    Krisztian Galanthai-Fekete

    Solution 2. step 2. is not clear and witout proper extended description I do not know what is missing from the description part: "A data set will be automatically generated. Change the data set name if you prefer and set and the value of the email field starting with "auto""

    Edited by Krisztian Galanthai-Fekete
    0
    Comment actions Permalink
  • Avatar
    Joseph Hamdan

    Hi Krisztian,

    Here are steps:
    1. Enable the option Timestamp on your data template
    2. Inject the data template on a step with Write command
    3. Execute the step. You will see the result showing the value from your dataset as well as a unique timestamp from the time in which execution occured.

    Regards,
    Subject7 Team

    0
    Comment actions Permalink

Please sign in to leave a comment.