loop Validation : Automation Tools

loop Validation

Ranorex Spy, Recorder, and Studio.

loop Validation

Postby sathitth » Wed Jan 19, 2011 12:27 pm

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
sathitth
 
Posts: 1
Joined: Wed Jan 19, 2011 11:09 am

Re: loop Validation

Postby Support Team » Wed Jan 19, 2011 1: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
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to Automation Tools

Who is online

Users browsing this forum: No registered users and 0 guests