How to write QTP results to a text file or an Excel file ?

I need to write the QTP results to a text file or an Excel file as i don't want to see the results in QTP results window.

Please Can anybody provide the exact code for it
Urgent...............................

Thanks in advance
Uday

Editorial / Best Answer

Answered by: srinivas Potnuru

  • Jun 6th, 2006


Hi all,

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

Showing Answers 1 - 12 of 12 Answers

William

  • May 23rd, 2006
 

this is the function to create and write a notepadSub CreateFile() Dim fso, tf Set fso = CreateObject("Scripting.FileSystemObject") Set tf = fso.CreateTextFile("c:\testfile.txt", True) ' Write a line with a newline character. tf.WriteLine("Testing 1, 2, 3.") ' Write three newline characters to the file. tf.WriteBlankLines(3) ' Write a line. tf.Write ("This is a test.") tf.CloseEnd Subwe can call this function in our main script wherever we need to report

  Was this answer useful?  Yes

this is the function to create and write a notepad Sub CreateFile() Dim fso, tf Set fso = CreateObject("Scripting.FileSystemObject") Set tf = fso.CreateTextFile("c:\testfile.txt", True) ' Write a line with a newline character. tf.WriteLine("Testing 1, 2, 3.") ' Write three newline characters to the file. tf.WriteBlankLines(3) ' Write a line. tf.Write ("This is a test.") tf.CloseEnd Subwe have to save this as .vbs file and add in the resources of test settingsand we can call the function in the script wherever we want to report

  Was this answer useful?  Yes

srinivas Potnuru

  • Jun 6th, 2006
 

Hi all,

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

Mahendra

  • Jan 18th, 2007
 

Please can any one tell me the what does  these functions means
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
What does these paramaters are.( sTablePath,sStatus,sFunctionality,sDescription)
Thanx In advance
Mahendra

hk

  • Feb 23rd, 2007
 

Can somebocdy explain  how to  specify the parameters needed to call  these functions?

  Was this answer useful?  Yes

SumalathaK

  • Jul 9th, 2007
 

Hi all,
I want to update a detailed Test Result report to Td, i dont want to save all the test cases results in to one folder. I want to display the test case name as the TEst Name (not the script name) and all the steps that were executed should display under the particular test case .
To accomplish this task i am planning to write the results to excel sheet and i want to import the sheet and write the result to TD. but i dont have any idea how to implement this.
Can anybody tell me  how to update the test results to TD
It's Really urgent.
Thanks,
Suma

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions