简体   繁体   English

UFT-API 试运行时可以定义excel文件来导入数据吗?

[英]UFT-API It is possible to define the excel file to import data during the test run?

I have several tests that can use several excel data files.我有几个测试可以使用多个 excel 数据文件。

Now, each time that a need to change the data excel file for a test... I need to do it mannually in UFT.现在,每次需要更改数据 excel 文件以进行测试时……我需要在 UFT 中手动执行此操作。

My idea is to have a simple configuration file (txt), that will define what data excel file to use on the actual run of the actual test.我的想法是有一个简单的配置文件 (txt),它将定义在实际测试的实际运行中使用的数据 excel 文件。

Thanks谢谢

QTP's design lends well to stackable parameterization... For example here, you can use parameterization to control your parameterization ;) 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" 

Or, you could even put all the data in one workbook on different sheets and include a column that names the data sheets...或者,您甚至可以将所有数据放在不同工作表上的一个工作簿中,并包括一列命名数据表...

DataTable.AddSheet "Config"
DataTable.ImportSheet ("Config", "c:\Automation\Config.xls")

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

So, you setup your test by editing Config.xls to control which datasheet ends up in the "Data" sheet in the QTP datatable :)因此,您可以通过编辑 Config.xls 来设置测试,以控制 QTP 数据表中的“数据”表中的最终数据表:)

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

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