How to count total Local Data rows for Data Driven testing and then perform a function on a particular row?

185 views Asked by At

I'm writing test automation scripts that is based on Data Driven testing for Web Browser test. I'm using Local Data as my data source.

Eg: Local Data table contains 2 rows and 2 columns for Username and Password.

I'm wondering is there is a way to perform a row "Count" function for the Local Data table.

And then,if the row count is two, perform a specific function.

The idea is something like this :

if LocalData.Row = 2 then 
     //Execute a function
else
     //Close Browser

I can't seem to find any resources in the net for this. I'm just being introduced to Telerik so i'm learning as it goes and i'm really hoping you guys can help to give some pointers on this question.

Many many thanks in advance :)

1

There are 1 answers

0
Drag and Drop On BEST ANSWER

Column and row are two different things.

When accessing the column by the RAD_Grid.MasterTableView.Columns.

You will be able to modify all the properties of a column. Like :
FilterDelay, CurrentFilterFunction, ShowFilterIcon, DataField, UniqueName, Display, Exportable...

foreach (GridColumn column in RAD_Grid.MasterTableView.Columns)
{
    if (column is GridBoundColumn)
    {
        GridBoundColumn boundColumn = column as GridBoundColumn;
        boundColumn.CurrentFilterValue = string.Empty;
    }
}

To iterate through the row, on the data bound:

protected void Unnamed_DataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
       GridDataItem item = (GridDataItem)e.Item;
       // LOGIC
    }

    //Total Item Count:
    if (e.Item is GridPagerItem)
    {
        int itemsCount = ((GridPagerItem)e.Item).Paging.DataSourceCount;
    }
}

Or

GridItemCollection gridRows = RAD_Grid.Items;
int i;
foreach (GridDataItem data in gridRows)
{    
    i++;
    ItemClass obj = (ItemClass)data.DataItem;
}

As its not really clear what you want I will give you an other way around. In your grid put a templated Column. I' am pretty sure that's what you are looking for. And if the logic is complexe put it in a function in code behind and simply :

<asp:Label ID="lbl_Exmpl" runat="server"
     Text=' <%# MyFunction( Convert.ToInt32(Eval("Mydata")) ) %>' />