简体   繁体   English

使用UFT读取Excel更新

[英]Reading Excel updates with UFT

Hi everyone, 嗨,大家好,

I'am using HP UFT for testing. 我正在使用HP UFT进行测试。

I get data from an Excel file and also write data to the same Excel file. 我从Excel文件中获取数据,也将数据写入同一Excel文件中。 My issue is that when i write data to the Excel file, I can't use it until the test is closed and UFT stops running (UFT won't read it, it's still blank to it). 我的问题是,当我将数据写入Excel文件时,直到测试关闭并且UFT停止运行(UFT不会读取它,它仍然为空白),我才能使用它。

I need a way to update UFT "view" of the Excel while running, i can't just close and open again the Excel file while test is still running. 我需要一种在运行时更新Excel的UFT“视图”的方法,我无法在测试仍在运行时关闭并再次打开Excel文件。

Language used: VBScript 使用的语言:VBScript

Can you help me? 你能帮助我吗?

Thank you all 谢谢你们

You should use the UFT DataTable . 您应该使用UFT DataTable The DataTable utility object gives you ways to import the Excel File programmatically at the beginning of the Test, write the files to there and when it ends, dump it back to a file. DataTable实用程序对象为您提供了在测试开始时以编程方式导入Excel文件,将文件写入其中并在结束时将其转储回文件的方法。 As a Bonus, you would also be able to see the DataTable content in the RunReports at the end(under the Data Tab) 作为奖励,您还可以在最后的RunReports中查看DataTable内容(在Data选项卡下)

Do not forget that everything you do on the DataTable while running the test is written into the memory only. 不要忘记,在运行测试时在DataTable上执行的所有操作仅被写入内存。 In case the test cannot reach the end where you persist it again, all is lost. 万一测试无法达到您再次坚持的目的,所有内容都会丢失。 You can try error handling with On Error Resume Next, Recovery Scenarios or Class_Terminate based destructors (Create and instantiate a Dummy class, and if the test crashes and stops the Class_terminate will automatically be called where you can do cleanup activities. 您可以尝试使用On Error Resume Next,Recovery Scenarios或基于Class_Terminate的析构函数(创建并实例化Dummy类,并且如果测试崩溃并停止,则Class_terminate将被自动调用,您可以在其中执行清理活动)进行错误处理。

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

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