Ask a Question

"Unknown Variable Container" Message

6578
New Contributor

"Unknown Variable Container" Message

Hello, everyone!

 

Using the Generate Data option, I created a table (12x2000) but I receive an exception (A row index must be an integer value) every time I attempt to use any of it. In doing some reading through the board, I saw someone else had difficulty which was resolved when adjusting the variable values and removing the trailing quotations and comma:

 

ProjectSuite.Variables.ComplaintData("ConsumerPhoneNumber", "")

 

When I do this and click "Finish", I get the ""Unknown Variable Container" message. Anyone have any thoughts on this?

6 REPLIES 6
Kitt
Regular Contributor

You get this message after you click Finish from the Data Generator Wizard?

8Kit_1-1659101666467.png

Or when you attempt to use the table variable in your scripts? I would start by checking to see how your project variable was saved (is the Type = Table or DB Table? is there data in the table?):

8Kit_3-1659102602505.png

 

and if you wanted to extract random data from this generated table you could do so by referencing this [TestComplete guide] -  Here is an example of how you might return a random phone number from your table:

 

 

function test() {
  var value;
  var randoRowNum = getRandomInteger(1, 2000);
  var randoPhoneNum = ProjectSuite.Variables.Var1.Item(9, randoRowNum);
  
  Log.Message("random row = " + randoRowNum + " | random phone number = " + randoPhoneNum);
}

function getRandomInteger(min, max) {
  var intMin = min;
  var intMax = max;
  if (equal(intMin, null) && equal(intMin, null)) {
    intMin = 1;
    intMax = 10;
  }
  return Math.round(Math.random()*(intMax-intMin)+intMin);
}

 

 

and here is the log returning the value from a random row in column 9 (phone#):

8Kit_2-1659102422081.png

 

Since you are using Keyword tests, I would also give this a look [TestComplete reference]

[[ kITt: keep IT testing ]]
6578
New Contributor

Thanks, @Kitt !

 

After reading your response and looking into it some more I was able to get the generated data entered into the keyword tests. Now that the data is going in, however, the test will just start over. I currently have it set to go from the beginning of the sheet to the end, which I suspect is the cause here. If I specify the start / end record to a given number, won't it keep reusing the same data or am I misunderstanding?

Kitt
Regular Contributor

@6578 Each time you run the test() function in my example, it should retrieve a different phone number to use during that test run. I am accomplishing this by using a custom function called getRandomInteger() to return a random number between x and y. In my example I'm passing the size of your table to getRandomInteger(1, 2000), since you have 2000 records. 

line 2: var randoRowNum = getRandomInteger(1, 2000);
line 3: var randoPhoneNum = ProjectSuite.Variables.Var1.Item(9, randoRowNum);

Line 2 would set the randoRowNum variable as the random number that is returned at runtime. 

Line 3 would use that random rowX number to find a value in column 9, rowX (AKA your phone numbers) and set it as a variable that you can reference in your tests as randoPhoneNum, which should remain the phone number used throughout the test.

 

If you re-ran the test() function 5 times, it should find a different phone number each time. Not sure if this answers your question, but I may have misunderstood your inquiry.

[[ kITt: keep IT testing ]]
Kitt
Regular Contributor

Can you please reiterate where you are receiving this error within TestComplete and what steps you are performing? I could not produce any errors and was able to use the Data Generator in my tests/scripts using the example in my previous post, so I'm just trying to understand a bit more about how your project is set up and what's triggering the "Unknown Variable Container" message. 

 

I am using TC v15.42.9.7 x64

[Prepare TC Project for DDT] 

[[ kITt: keep IT testing ]]
6578
New Contributor

The message was gone once I added in the data loop which, as I understood it, is what needs to be done to get the data to populate randomly from the generated data. What I am running into now is the test running over and over instead of just the once. Is this something that will have to be resolved by using the scripts only? Don't have much experience in that area and would honestly like to avoid if possible.

Kitt
Regular Contributor

I'm no keyword expert, so consider this a stab in the dark...assuming you have followed the TC references for data driven loops [here] and [here], you may want to run through the Data-Driven Loop wizard again and check your configuration:

 

By default, the data-drive loop operation processes all records of the specified storage. If you want to specify the start and end records for processing, enter their identifiers into the From Record and To Record edit boxes respectively.

 

Could you share a screenshot of your loop and table parameters (like below)? 

8Kit_1-1660053811155.png

8Kit_2-1660054291252.png

Check the Data Generator 'Generation Mode' setting and see if your column is set to Random or Sequential.

 

[[ kITt: keep IT testing ]]
cancel
Showing results for 
Search instead for 
Did you mean: