Search code examples
exceltestingvbscripthp-uft

Reading Excel updates with UFT


Hi everyone,

I'am using HP UFT for testing.

I get data from an Excel file and also write data to the same Excel file. 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).

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.

Language used: VBScript

Can you help me?

Thank you all


Solution

  • You should use the 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. As a Bonus, you would also be able to see the DataTable content in the RunReports at the end(under the Data Tab)

    Do not forget that everything you do on the DataTable while running the test is written into the memory only. 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.