Forum Discussion

Sys2k's avatar
Sys2k
Occasional Contributor
10 years ago

KeywordTests - Setting Random/Counter Variables

Looking for a simple way through KeywordTests to set a Random or Counter Variable.

 

So when I'm setting say: 'Username1' the next run through will automatically update itself to 'Username2'.

 

Or

 

Our program requires the entering of a 17 digit VIN number, I would like to be able to generate a random 17 digit variable to fill in that field.

 

 

I don't have too much programming knowledge for the script side of TestComplete yet so I was wondering what options are available to solve this through KeywordTests.

 

 

However if there is no way to do that through KeywordTests, how would I do the script function for these?

  • There is some explanation here about generating data:

    https://support.smartbear.com/viewarticle/71023/

    I would use the above examples to generate your VIN numbers.

     

    For Username1, etc., create a persistent integer variable MyCounter for the counter.

    Increment it with Set Variable Value at the top of your test:  

       Set Variable Value  MyCounter  MyCounter + 1

    Create a persistent string variable MyUserName to hold your user name and set it with a Code Expression inside Set Variable Value:

       Set Variable Value  MyUserName  "Username" + aqConvert.IntToStr(MyCounter) 

     

     

  • There is some explanation here about generating data:

    https://support.smartbear.com/viewarticle/71023/

    I would use the above examples to generate your VIN numbers.

     

    For Username1, etc., create a persistent integer variable MyCounter for the counter.

    Increment it with Set Variable Value at the top of your test:  

       Set Variable Value  MyCounter  MyCounter + 1

    Create a persistent string variable MyUserName to hold your user name and set it with a Code Expression inside Set Variable Value:

       Set Variable Value  MyUserName  "Username" + aqConvert.IntToStr(MyCounter)