Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to update Pass/Fail in Excel using Vbscript
#1
Not Solved
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
Reply
#2
Not Solved
Learn about Createobject("Excel.Application")
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply
#3
Not Solved
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
Reply
#4
Not Solved
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.
Reply
#5
Not Solved
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is VBScripting disabled in Office 365 update? soumyarani 0 1,246 12-19-2020, 12:37 PM
Last Post: soumyarani
  how can i click a macro button in excel using vbscript arpan 1 3,579 10-03-2017, 06:27 AM
Last Post: supputuri
  Pass reference to datatable into function smallsteve 2 1,880 09-28-2017, 09:18 PM
Last Post: smallsteve
  UFT 12.02 Compatibility for IE 11.0 : Fail to identify the defined Object Amruta_121 9 10,482 01-11-2016, 12:45 PM
Last Post: vinod123
  Can you please help me in QTP DP to pass the variable name anshika.agarwal 1 2,590 09-04-2014, 06:43 PM
Last Post: anshika.agarwal

Forum Jump:


Users browsing this thread: 1 Guest(s)