Micro Focus QTP (UFT) Forums
How to update Pass/Fail in Excel using Vbscript - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: How to update Pass/Fail in Excel using Vbscript (/Thread-How-to-update-Pass-Fail-in-Excel-using-Vbscript)



How to update Pass/Fail in Excel using Vbscript - anji2010 - 07-02-2009

How to update Pass/Fail in Excel using Vbscript

TCID Action property Expeted Actual Pass/Fail

thses are the columns in excel . based on the "Action" keyword i wrote a function which returns pass/fail .

how to update that pass/fail in excel sheet for that column "Pass/Fail" of that "Action " based on pass or fail returned

Please help me

thanks in advance


RE: How to update Pass/Fail in Excel using Vbscript - basanth27 - 07-03-2009

Learn about Createobject("Excel.Application")


RE: How to update Pass/Fail in Excel using Vbscript - ursvinod - 07-03-2009

Hi,

Below is the solution,

Code:
Set qtApp = CreateObject("QuickTest.Application")
Set qtTest = qtApp.Test
Run_Status = qtTest.LastRunResults.Status ' This will give you the status of the Run i.e Pass or Fail.
Set appExcel = CreateObject("Excel.Application")
Set objWorkBook = appExcel.Workbooks.Add '
Set objWorkSheet =  objWorkBook.WorkSheets.Add
appExcel.Cells(2,2).Value = Run_Status'= This will update the status of the test in 2nd row and 2nd column in the worksheet
appExcel.ActiveWorkbook.SaveAs "c:\Results.xls"
appExcel.Quit

Use the above code at the end of out script.

- Vinod


RE: How to update Pass/Fail in Excel using Vbscript - ritesh - 07-06-2009

Hi Vinod,

Can u please explain in little bit detail. Bcoz i'm getting output as 'Running'.

I use the following steps to update the result in excel:
1) I have written a function called ResultEntry() and saved it inside a VB file.
2) I call this function at the end of each test case.

Here is the ResultEntry function

Code:
Public Function ResultEntry(TestCaseId, TestCase, Desc, Result)
   MyTime=Now
   MyFile.Write(TestCaseId)
   MyFile.Write(",")
   MyFile.Write(TestCase)
   MyFile.Write(",")
   MyFile.Write(Desc)
   MyFile.Write(",")
   MyFile.Write(Result)
   MyFile.WriteLine("")
End Function

And I call this function at the end of the each test case inside the If loop like:

Code:
If (Pass condition) Then
ResultEntry "ID", "Test Case", "Description", "Pass"
Else
ResultEntry "ID", "Test Case", "Description", "Fail"

Please let me know if I'm wrong or even if I can improve the steps what i'm following.


RE: How to update Pass/Fail in Excel using Vbscript - KVK - 07-13-2009

Hi Ritesh,

Code:
Run_Status = qtTest.LastRunResults.Status

The above statement will return the current run status of the test.

You have to use this statement only at the end of your script i.e end of last action in your test. If there are any other actions that need still needs to run then the run status will be Running.

Please try this and let me know..
Hi Ritesh,

The above code that Vinod pasted can not be used in QTP instead use the same code in a vbs file and then run the vbs file. It works perfectly Smile

Code:
Set QtpApp = CreateObject("QuickTest.Application")
QtpApp.Launch
QtpApp.Visible = True
QtpApp.Open "C:\TestScript"
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create
the Run Results Options object
qtResultsOpt.ResultsLocation = "C:\TestScrip" ' Set the results
QtpApp.Test.Run ' Run the test
MsgBox QtpApp.Test.LastRunResults.Status ' Check the results of the test  run
QtpApp.Close

Paste the above code in a vbs file(*.vbs) and run the vbs file.

Let me know if it works Smile