This is a migrated thread and some comments may be shown as answers.

Increment Usernames

5 Answers 71 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 1
Sean asked on 14 Dec 2015, 07:56 PM

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?

5 Answers, 1 is accepted

Sort by
0
Sailaja
Top achievements
Rank 1
answered on 15 Dec 2015, 06:14 AM

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

 

 

 

0
Sean
Top achievements
Rank 1
answered on 15 Dec 2015, 10:39 PM
I will give that a try. Thanks!
0
Boyan Boev
Telerik team
answered on 17 Dec 2015, 08:52 AM
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!
0
Sean
Top achievements
Rank 1
answered on 17 Dec 2015, 07:18 PM

Hey Sailaja

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

 

Thanks,

Sean

0
Boyan Boev
Telerik team
answered on 18 Dec 2015, 02:55 PM
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!
Tags
General Discussions
Asked by
Sean
Top achievements
Rank 1
Answers by
Sailaja
Top achievements
Rank 1
Sean
Top achievements
Rank 1
Boyan Boev
Telerik team
Share this question
or