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

时间:2016-05-03 10:29:55

标签: excel api hp-uft

我有几个可以使用多个Excel数据文件的测试。

现在,每次需要更改数据excel文件进​​行测试时...我需要在UFT中手动执行。

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

由于

1 个答案:

答案 0 :(得分:0)

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:\Automation\Config.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:\Automation\Config.xls")

DataTable.AddSheet "Data"
DataTable.ImportSheet (DataTable("Filename","Config"), DataTable("Sheetname","Config"), "Data")

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

相关问题