Forum Discussion

tbroyles's avatar
tbroyles
New Contributor
12 years ago

Increment Creating New Users

I am trying to create new users and incrementing each time I run the test.

NewUser1, NewUser2, NewUser3.....for example.

I have looked through the forum and nothing I have tried has worked.



I created a new integer with the Default Value of 1

I then Set the Variable Value to Code Expression Mode with the Value of KeywordTests.Test2.Variables.NewUser + 1

(The name of my variable is NewUser)



What am I doing wrong????



Terisa
  • joffre's avatar
    joffre
    Regular Contributor
    Hello Terisa. How are you doing? I'm using JScript, but the idea is the same as below.


    var count = 0



    while (count < 10)



    {



     Log.Message("NewUser" + count);



     count = count + 1;



    }


  • joffre's avatar
    joffre
    Regular Contributor
    Now with the code formatted:




    var count = 0

    while (count < 10)

    {

     Log.Message("NewUser" + count);

     count = count + 1;

    }



    Hope this can help.


  • Hi Terisa,



    If I understand, you have two variables:


    • A counter with default value 1


    • The user name stored in KeywordTests.Test2.Variables.NewUser


    I think the problem is that you are adding a 1 to the user name, so if the user is called "NewUser" and you add "1" you will always get "NewUser1".



    What you have to do is add the counter to the user name, not just "1". Also, do not store the variable once you added the counter, as yoy will concatenate the counter, and you will get "NewUser12", "NewUser123" and so on.



    Hope it helped!