I have a module that works fine when debugging, but fails when run as part of the test suite.
I am trying to pick an item from a grid.
Here is my code:
Code: Select all
public void SelectUserFromSearchResults()
{
// this looks in the Search Results table for varSelectedUser and returns the index of this row as varIndex
Ranorex .Table myTable=repo.SelectUsersOrGroups.UsersTable.SelectUsersOrGroupsAdvanced.Table282;
IList<Row> rows = myTable.FindDescendants<Row>();
int selectedIndex=-1;
bool found=false ;
foreach (Row row in rows )
{
foreach (Cell cell in row .Cells )
{
string value=cell .Text;
if(value.Contains (varSelectedUser))
{
selectedIndex=row .Index ;
varIndex =selectedIndex.ToString () ;
found =true ;
break ;
}
if(found )
{
break ;
}
}
if(found )
{
break ;
}
}
if(!found )
{
Report.Log(ReportLevel.Failure , "Search", "Validating Exists on item 'SelectUsersOrGroups.UsersTable.Table282'.", repo.SelectUsersOrGroups.UsersTable.SelectUsersOrGroupsAdvanced.Table282Info);
}
Report.Log(ReportLevel.Info, "Validation", "Validating Exists on item 'SelectUsersOrGroups.UsersTable.Table282'.", repo.SelectUsersOrGroups.UsersTable.SelectUsersOrGroupsAdvanced.Table282Info);
Validate.Exists(repo.SelectUsersOrGroups.UsersTable.SelectUsersOrGroupsAdvanced.Table282Info);
Report.Log(ReportLevel.Info, "Mouse", "Mouse Left DoubleClick item 'SelectUsersOrGroups.UsersTable.SearchResultsGrid.SelectedDomainUsers' at 46;14.", repo.SelectUsersOrGroups.UsersTable.SelectUsersOrGroupsAdvanced.SelectedDomainUsersInfo);
repo.SelectUsersOrGroups.UsersTable.SelectUsersOrGroupsAdvanced.SelectedDomainUsers.DoubleClick("46;14");
}
}
Is there any way I can refer to this directly in code?table/row[@index=$varIndex]/cell[@text=$varselecteduser]
I have added the two variables varIndex and varSelectedUser in the Recording Module, and have also added them as Parameters in the Test Case.
I don't understand. The code works a treat when I run it in isolation from the ranoprex Studio with breakpoints.