Ask a Question

KeywordTests - Setting Random/Counter Variables

SOLVED
Sys2k
Occasional Contributor

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Marsha_R
Community Hero

Re: KeywordTests - Setting Random/Counter Variables

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) 

 

 

View solution in original post

1 REPLY 1
Marsha_R
Community Hero

Re: KeywordTests - Setting Random/Counter Variables

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) 

 

 

View solution in original post

cancel
Showing results for 
Search instead for 
Did you mean: