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?

    Thanks,
    Mark
  2. Answer
    Stoich
    Admin
    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:
    http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/knowledge-base/data-driven-testing/extracted-variables-in-code.aspx

    Once set, you can access this value without code (i.e. use it as a parameter) in the same way as normal databinding:
    http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/data-driven-testing/attach-columns-to-input-values.aspx

    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:
    http://www.c-sharpcorner.com/UploadFile/mahesh/RandomNumber11232005010428AM/RandomNumber.aspx

    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))) ;
    builder.Append(ch);
    }
    this.SetExtractedValue("myRandomString",builder.ToString().ToLower());

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

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

    Greetings,
    Stoich
    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