0

我试图弄清楚如何使用 Ranorex 中的“ExcelDataConnector”类来访问 Excel 数据,以便我们可以构建动态测试用例交互。

ExcelDataConnector con;
con = new ExcelDataConnector("Test", "C:\\Users\\jonas\\Desktop\\Test.xlsx", "Setup", "", 0);
Report.Info(con.FileName);

所以我想我已经连接到数据源。但是我从这里做什么?

我正在查看文档,但我不知道使用什么方法来获取数据或遍历记录。

ExcelDataConnector 类

还是我在这里完全断章取义?

我开始觉得我误解了这门课以及它的用途。

如果有人能证实或否认我的怀疑,我将不胜感激。如果这就是你应该如何使用这个类,请提供一些例子让我继续。

4

1 回答 1

1

这有很多信息:测试自动化中的 10 个最佳实践 #5:数据驱动测试

这只是您可以在那里看到的示例:

public ExcelConnector(string excelFile, string[] inputs, string[] outputs, bool load, UInt16 startRow)
{
    this.excelFile = excelFile;
    this.inputs = inputs;
    this.outputs = outputs;
    if (load)
        this.LoadFile();
    currentRowIndex = startRow;
}

public void LoadFile()
{
    excelObj = new Excel.Application();
    System.Threading.Thread.CurrentThread.CurrentCulture = new
                                         System.Globalization.CultureInfo("en-US");
    workBook = excelObj.Workbooks.Open(this.excelFile, 0, true, 5, "", "", true,
                                         Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, false, false);
    Excel.Sheets sheets = workBook.Worksheets;
    worksheet = (Excel.Worksheet)sheets.get_Item(1);
}
于 2013-07-24T17:42:23.957 回答