loop Validation

Ranorex Spy, Recorder, and Studio.
sathitth
Posts: 1
Joined: Wed Jan 19, 2011 10:09 am

loop Validation

Post by sathitth » Wed Jan 19, 2011 11:27 am

Hello,

I am a new to Ranoex and currently evaluating the product.

I have
1.1) a table with 1 columns and 5 rows
Cell1
Cell2
Cell3
Cell4
Cell5
1.2) a .csv file with following contents
A
B
C
D
E

I want Ranorex to
2.1) Enter the above characters (A-E) into each cell e.g. "A" in "Cell1".
Which is working O.K.
"A-E" are in their position correctly.
2.2) I want the validation for each cell.
However, validation can only validate "Cell1: which has "A" but not the rest. In the second round of automate validation, it took "B" from .csv and validate against the "cell1" which has "A" in. This result in validation failure.

Thanks
SATHITTH

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: loop Validation

Post by Support Team » Wed Jan 19, 2011 12:50 pm

Hi,

you have to somehow iterate thru your cells depending on which loop of automation you are.
So if you take the Data Driven Test Example delivered with Ranorex you can validate the values in column "First Name" with following code customisations:

Add a pass number to your AddVip class:
public static int PassNumber
{   
  get;set;  
}
Set this poperty for every autoamtion loop:
int PassNumber = 0;
foreach(DataRow row in csvConnector.Rows)
{          		
  AddVIP.FirstName = row["FirstName"].ToString();
  AddVIP.LastName = row["LastName"].ToString();
  AddVIP.Gender = row["Gender"].ToString ();
  AddVIP.Category = row["Category"].ToString ();

  AddVIP.PassNumber = PassNumber++;

  AddVIP.Start();
}
Add a user code item which validates a cell depending on the pass number:
public static void ValidateVIP()
{
  string rxPath = String.Format("./table/row[@accessiblename='Row {0}']/cell[1]", 
                                PassNumber.ToString());
  Ranorex.Cell cell = null;
  bool found = repo.FormVIP_Database.Self.TryFindSingle(rxPath,out cell);
  if (found)
  {
    Validate.Attribute(cell, "Text", FirstName);
  }
  else
  {
    Report.Warn("The given row (Row " + PassNumber.ToString() + ") was not found.");
  }                                                              
}
Regards,
Tobias
Support Team
.
Image