Increment Usernames

6 posts, 0 answers
  1. Sean
    Sean avatar
    14 posts
    Member since:
    Jul 2015

    Posted 14 Dec 2015 Link to this post

    Hello,

    I am new to Test Studio. I am creating a script that creates a new user account.  Is there an easy was to increment the username by one everytime the script runs?

  2. Sailaja
    Sailaja avatar
    7 posts
    Member since:
    Dec 2014

    Posted 15 Dec 2015 in reply to Sean Link to this post

    Hi Sean,

    Instead of incrementing it by one, I suggest to append current timestamp to the username which has more advantages compared to appending one. One advantage example is you can easily identify at what time the scripts failed just by seeing the id

    Below is the code for appending timestamp for usernames

     public string getUsername()
            {
                DateTime time = DateTime.Now;           
                string format = "dMMMdddhhmmyyyy"; // This you can change according to your need.
                String username= "username_" + time.ToString(format) + DateTime.Now.Millisecond;
                return username.ToLower();
            }

     

    output : username_15dectue11172015468

    cs_um_18augtue06172015468

    Hope this information helps you.

    Regards,

    Sailaja

     

     

     

  3. Sean
    Sean avatar
    14 posts
    Member since:
    Jul 2015

    Posted 15 Dec 2015 in reply to Sailaja Link to this post

    I will give that a try. Thanks!
  4. Boyan Boev
    Admin
    Boyan Boev avatar
    1040 posts

    Posted 17 Dec 2015 Link to this post

    Hi,

    @Sean, please try out the suggestion from Sailaja and let us know that works for you.

    @Sailaja, thank you again for helping and sharing knowledge.

    Thank you!

    Regards,
    Boyan Boev
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  5. Sean
    Sean avatar
    14 posts
    Member since:
    Jul 2015

    Posted 17 Dec 2015 in reply to Boyan Boev Link to this post

    Hey Sailaja

    This might a dumb question, but where should I put the code above?

     

    Thanks,

    Sean

  6. Boyan Boev
    Admin
    Boyan Boev avatar
    1040 posts

    Posted 18 Dec 2015 Link to this post

    Hello Sean,

    You should insert the code in a coded step.

    Please see this article which describes the process in details.

    Let me know further assistance.

    Regards,
    Boyan Boev
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
Back to Top