Automated unique registration value

2 posts, 1 answers
  1. Mark Cooper
    Mark Cooper avatar
    5 posts
    Member since:
    Sep 2005

    Posted 09 Sep 2011 Link to this post

    I'm testing the registration form for my application. I want to use a unique email address (either an incremental integer or maybe a date string).

    Is this possible to do via the QA version without writing code? If, not, what other approaches are there to get this working?

    Is it possible to then parameterise this value for use by other test steps?

  2. Answer
    Stoich avatar
    1 posts

    Posted 12 Sep 2011 Link to this post

    Hi Mark,
        you"ll need a coded step for this but it won't be complex to implement.

    First off: in code you can set a so-called Extracted Value:

    Once set, you can access this value without code (i.e. use it as a parameter) in the same way as normal databinding:

    So you just need to write the code that generates a random String in a coded step and then set it as an Extracted Value. From there you can access it without any further coded steps. Generating a random String is very straightforward. I followed the following tutorial:

    Here's what my code step looks like:
    StringBuilder builder = new StringBuilder();
    Random random = new Random();
    char ch ;
    for(int i=0; i<7; i++)
    ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;

    You can access this value by using $(myRandomString).

    Let me know if you require any additional assistance with this.

    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top