简体   繁体   English

如何为数据驱动测试计算本地数据总行数,然后在特定行上执行功能?

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

I'm writing test automation scripts that is based on Data Driven testing for Web Browser test. 我正在编写基于Web浏览器测试的数据驱动测试的测试自动化脚本。 I'm using Local Data as my data source. 我正在使用本地数据作为数据源。

Eg: Local Data table contains 2 rows and 2 columns for Username and Password. 例如:本地数据表包含2行和2列的用户名和密码。

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. 然后,如果行数为2,则执行特定功能。

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. 我只是被介绍给Telerik,所以我正在学习它,我真的希望你们能为这个问题提供一些指导。

Many many thanks in advance :) 在此先感谢很多:)

Column and row are two different things. 列和行是两个不同的东西。

When accessing the column by the RAD_Grid.MasterTableView.Columns . 通过RAD_Grid.MasterTableView.Columns访问列时。

You will be able to modify all the properties of a column. 您将能够修改列的所有属性。 Like : 喜欢 :
FilterDelay, CurrentFilterFunction, ShowFilterIcon, DataField, UniqueName, Display, Exportable... 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")) ) %>' />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM