UFT-API可以定义excel文件以在测试运行期间导入数据



我有几个测试可以使用几个excel数据文件。

现在,每次需要更改数据excel文件进行测试时。。。我需要在UFT中进行人工操作。

我的想法是有一个简单的配置文件(txt),它将定义在实际测试的实际运行中使用什么数据excel文件。

感谢

QTP的设计非常适合堆叠参数化。。。例如,在这里,可以使用参数化来控制参数化;)

'where Config.xls is an excel file with a tab/sheet called "Config" and a column called "Filename" that contains the filenames of the workbooks containing the data.
DataTable.AddSheet "Config"
DataTable.ImportSheet ("Config", "c:AutomationConfig.xls")
DataTable.AddSheet "Data"
DataTable.ImportSheet (DataTable("Filename","Config"), "Data", "Data") 'this assumes the data is on a sheet called "Data" in the excel file, and it ends up in the datatable as a sheet called "Data" 

或者,您甚至可以将一个工作簿中的所有数据放在不同的工作表上,并包含一列为数据表命名。。。

DataTable.AddSheet "Config"
DataTable.ImportSheet ("Config", "c:AutomationConfig.xls")
DataTable.AddSheet "Data"
DataTable.ImportSheet (DataTable("Filename","Config"), DataTable("Sheetname","Config"), "Data")

因此,您可以通过编辑Config.xls来设置测试,以控制哪个数据表最终出现在QTP数据表的"数据"表中:)

最新更新