Unified Functional Testing Practitioners Forum
cancel

How to send QTP test results into the excel sheet.

Highlighted
Devendra Sharma
Occasional Advisor

How to send QTP test results into the excel sheet.

How to send QTP test results into the excel sheet.

 

 

P.S. this thread has been moved from Quality Center Support and News Forum to Unified Functional Testing (formerly QTP) News and Support forum - HP Forums moderator

29 REPLIES
john scarpino
Honored Contributor

Re: How to send QTP test results into the excel sheet.

If you are running QTP from Quality Center. Within the Test Lab module, within the Execution Grid - multi-select within the Execution Grid tab {Ctrl + mouse select) then select on the top tool bar - 'Test Sets'/Export../'All' or 'Selected...'

The results based on what you filtered for the Execution Grid tab will be saved in .xls format.

I hope this helps.
john scarpino
Honored Contributor

Re: How to send QTP test results into the excel sheet.

This field might not be available as a filter from Mercury! Either call them and get an update or you will need to enter the data manually which might be the only way to go around this at this point.
yadav
Collector

Re: How to send QTP test results into the excel sheet.

We are not using QC...

can we export the result to excel sheet programmatically..???
CARTMAN_1
Frequent Visitor

Re: How to send QTP test results into the excel sheet.

You can use "DataTable.ExportSheet"' function at the end of ur script.
-------------
DataTable.ExportSheet("c:\name.xls","DTsheet")
------------------
where
DTsheet:index or name of the sheet which u want to export to the excel file.

Thanks,
Krishna
CARTMAN_1
Frequent Visitor

Re: How to send QTP test results into the excel sheet.

or you can use

DataTable.Export("C:\xyz.xls")

to export the entire sheet .

Thanks,
Krishna
yadav
Collector

Re: How to send QTP test results into the excel sheet.

I think you did not get my question.

I want to export the result generated by QTP after execution of the script to an excel sheet.

yadav
Collector

Re: How to send QTP test results into the excel sheet.

Solution you have given can only send the runtime values in the Datatable to an excel sheet.


Please correct me if I am doing some thing wrong.

Thanks

Parveen
rama suda
Regular Collector

Re: How to send QTP test results into the excel sheet.

Hi Yadav,
Try the below code to save the results


Dim strTestPath ' full filepath to the test
strTestPath = "C:\Program Files\Mercury Interactive\QuickTest Professional\Tests\testresultsexample"

' Launch QuickTest
Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Start QuickTest
qtApp.Visible = True ' Make the QuickTest application visible

' Run the Test
qtApp.Open strTestPath, False ' Open the test Set qtTest = qtApp.Test
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object

testres = "C:\temp\Res1" ' Original location for the test results.
qtResultsOpt.ResultsLocation = testres ' Specify the location to save the test results.
qtTest.Run qtResultsOpt, True ' Run the test and wait until end of the test run

' Close QuickTest Professional
qtApp.Quit

' Copy the test results to additional locations.
Set fso = CreateObject("Scripting.FileSystemObject")

fso.CopyFolder testres, "C:\temp\Res2_copy"
fso.CopyFolder testres, "C:\Program Files\Mercury Interactive\QuickTest Professional\Tests\testresultsexample\CopiedRes1"

Set fso = Nothing
Set qtResultsOpt = Nothing
Set qtApp = Nothing

this will work
all the best
Regards,
Rama

rama suda
Regular Collector

Re: How to send QTP test results into the excel sheet.

Yadav ,
The code i have given will store all the results into one folder
I think it is not possible to sotre the complete results in .xls but we can sotr them in HTML format

Regards,
Rama
rama suda
Regular Collector

Re: How to send QTP test results into the excel sheet.

Hi I am sorry
We can do that
below is the useful information


....................
Select the desired Export format:

Short - Exports a summary line (when available) for each item in the test results tree. This option is only available if you select All in step 2.
Detailed - Exports all available information for each item in the test results tree, or the selected branch, according to your selection in step 2.
///......
User-defined XLS - Allows you to browse to and select a customized .xls file. The customized .xls file allows you to specify the information to be included in the exported report and how it should appear. For information on customizing the .xls file, refer to the "Customizing the Test Results Display" section in the QuickTest Professional User's Guide (Mercury QuickTest Professional User's Guide -> Running and Debugging Tests -> Analyzing Test Results -> Customizing the Test Results Display).

Write the code to select the format dynamically

Ram

yadav
Collector

Re: How to send QTP test results into the excel sheet.


thanks for the reply!

Solution you have given just changes the result output file location that we can do this by just changing the location of the Result file when we initiate the execution.

What I want to do is, to export the results to excel sheet. just like we can export the result to a HTMl file from the result file that is being displayed after execution.

i.e In Test Result

File -> Export to HTML

option we have. but that only generates the HTML files.

also this is not what I need.

I need a script that generates result file as an Excel sheet.



thanks

Parveen

yadav
Collector

Re: How to send QTP test results into the excel sheet.

Hi

I tried that already that also doesn't work for my problem. IT just creates the ".xsl" file NOT excel sheet.
rama suda
Regular Collector

Re: How to send QTP test results into the excel sheet.

I have attached one screenshots
Have followed the same steps to export in to excel ?
Am i deviating from it?

thanks
Ram
CARTMAN_1
Frequent Visitor

Re: How to send QTP test results into the excel sheet.

Hi Yadav,
please check the attached file ,is that something u want ?

Thanks,
Krishna.
yadav
Collector

Re: How to send QTP test results into the excel sheet.

Thanks for the reply!


Rama process you have provided,in my system it just exports the Favorites to excel file.


and Krishna I have already tried this thing. and this is not what I need.

I need result in a formated file like we get when we export result into HTML file.


also,I want to do it through script.

rama suda
Regular Collector

Re: How to send QTP test results into the excel sheet.

Hi Yadav,
I am sorry for the wrong process
I have done this one in indirect method but the results in the .xls format not as html results .
Following are steps
1.First export the results in to HTML format
2.Save that file as .txt file and then save this txt file as .xls
It is showing all the results whatever available in the HTML format but as mentioned not in the good format .we need to do some manual settings for alignments

Apart from this i could not find any other way to store the resluts in .xls format

I hope that u can write the code for the same


Thanks
Rama

yadav
Collector

Re: How to send QTP test results into the excel sheet.

Hi Rama,

There is no need to follow these steps:

1. Export to HTML
2. Save as .txt file and then to .xls file

you can directly save the result with .xls extention at the time of exporting to HTML


But this is not what I am looking for..

I want to know how these Result files are generated by QTP. If we know the internal procedure then we can save the result in our desired format.

Result are generated by QTP with the help of four files

1. PDetails.xsl, PSelection.xsl, PStringTable.xsl

2. PResults.css( For formated result)

I need to know the logic how QTP uses these files to generate the Result.


rama suda
Regular Collector

Re: How to send QTP test results into the excel sheet.

Hi Yadav,
Have you tried by changing the any registry values ?
By using the default registry values the QTP will generate the results in the default formats.To change the default formats we need to do changes in the registry
...

Thanks
Rama
yadav
Collector

Re: How to send QTP test results into the excel sheet.

Hi,

which registry keys I need to change. I don't know about such thing.

Do you know which registry keys I need to change??
rama suda
Regular Collector

Re: How to send QTP test results into the excel sheet.

Hi,
By changing the registries we can generate HTML results along with xml default results but we could not generate results in .xls formatby default

To get report in HTML format have a look at thread QTP html results in this forums ( to cahne the registry and some code posted by marcel)
I think some dll files are required to generate the .xls format results and this should be done by HP it seems
Some tools are available to convert the different format .That logic should be incorporated with the QTP then i assume that your query will be solved

Rama
Cody Marcel
Honored Contributor

Re: How to send QTP test results into the excel sheet.

Have you thought about writing a custom reporting function? This function could take in the values you want to report and call both the normal reporter and write those same values to excel. You can interact with an excel sheet through the Excel object model.

You could then just replace your existing reporter statements with calls to the custom function.
yadav
Collector

Re: How to send QTP test results into the excel sheet.

You got it right Cody :)

I want to code a function that will direct all Reporter events to the excel file.
Along with there status.
arc_in
Acclaimed Contributor

Re: How to send QTP test results into the excel sheet.

We actually have few functions to add the results to the Excel File instead in the QTP Results Window.

Solution description: We will be using a seperate Sheet by name "Results" in which the Results of the Test will be appened.

There are 2 functions

1) initOutExcel(sTablePath)

Description : This function is to initialize a particular Excel Where you want to update the Results of the QTP Tests.

2) WriteResults(sTablePath,sStatus,sFunctionality,sDescription)

Description : This function appends the Result of a Test to the end of the existing results.

You can modify the below functions to suite your requitrement.

CODE:

Function initOutExcel(sTablePath)

Datatable.addSheet "Results"

Datatable.importSheet sTablePath, "Results","Results"

iParamCount = Datatable.getSheet("Results").getParameterCount

if iParamCount = 0 Then

Datatable.getSheet("Results").addParameter "S.No",""

Datatable.getSheet("Results").addParameter "Status",""

Datatable.getSheet("Results").addParameter "Functionality",""

Datatable.getSheet("Results").addParameter "Description",""

End If

Datatable.ExportSheet sTablePath,"Results"

End Function

Function WriteResults(sTablePath,sStatus,sFunctionality,sDescription)

Datatable.addSheet "Results"

Datatable.importSheet sTablePath, "Results","Results"

iRowCount = Datatable.getSheet("Results").getRowCount

Datatable.getSheet("Results").setCurrentRow(iRowCount+1)

Datatable("S.No","Results") = iRowCount+1

Datatable("Status","Results") = sStatus

Datatable("Description","Results") = sDescription

Datatable("Functionality","Results") = sFunctionality

Datatable.ExportSheet sTablePath,"Results"

End Function

Gaurav Varshne
Regular Collector

Re: How to send QTP test results into the excel sheet.

Hi,

I have implemented the above code but it throws an error. Stating "Error in Function Library."

Could you please quote the same code again with the example.

Thanks for the same.
//Add this to "OnDomLoad" event