UFT 11.53 how can I export output result window to a excel file
Is there way to export test results. I wanted to add code at the end of script to export output result window to excel file. There is option in UFT to configure and export to a file, but I want to add code in the script so that results will also be saved to a file at the end of each run. Is this possible? Is there a code already written that can be used with UFT?
Are you talking about the QTP report or something else?
Originally Posted by mwsrosso
yes, I have lots of print statement as the code is executing in output result window, I wanted them to be exported to my excel sheet at end of the test. is this possible. I guess it be like a log file of my code execution.
You can treat the print window like any other window, you can activate it then use sendkeys to select all text and copy it. Here's how to access the print window
Window("regexpwndtitle:=QuickTest Print Log").Activate
One drawback with using the window rather than a text or Excel log, what if the print window crashes or gets closed?
You can use Standard Output Value or text output value to collect the data from your result. Then, you can export the output result from data table to excel later by using a following syntax, DataTable.ExportSheet(FileName, DTSheet)
Hi Chomchalida are you saying I need to send each print statement to data sheet rather then output screen and then save that datasheet? Can you give me example please. Thanks
Originally Posted by Chomchalida
My meaning is if you print output into some of the window, you can use Standard Output Value or text output value (Design >> Output Value) by treating a window as any other standard windows. With the use of output function, the data shown in your result window will be recorded in datasheet automatically. Then, you can only export data in datasheet to excel file.
Originally Posted by szkapoo
Hope it clear to you.
Another issue of the print window as a log is that the print window has a maximum capacity. If you print a lot of text to it, you'll eventually lose the older statements in favor of the newer ones. What I did when I needed this sort of functionality was to write a function that would print to the output window with a timestamp and also to a text file. At the end of the test, I just saved the text file and it was identical to what had been printed to the output window.
It was something like this:
Public Function ReportItem(sStatus, sSummary, sDescription, bQTPLog, bOutputWindow, bTextFile)
' sStatus is micPass, micFail, micDone, etc.
' sSummary is a brief description of the item to report
' sDescription is the full text to report
' bQTPLog is a boolean switch for reporting to the QTP log or not
' bOutputWindow is a boolean switch for reporting to the output window or not
' bTextFile is a boolean switch for reporting to the text file or not.
' text file reference is held in a global variable and opened by another function OR you could pass in the path to the text file you want to write it to.
If bQTPLog Then reporter.reportEvent sStatus, sSummary, sDescription
If bOutputWindow Then print Format(now(), "hh:mm:ss") & "::" & sDescription
If bTextFile Then AppendToFile(sTextFilePath, Format(now(), "hh:mm:ss") & "::" & sDescription)
' Format is a function that formats text for me
' AppendToFile does exactly as advertised