ebodien
15 years agoContributor
OnStep Event
I'm attempting to create what I thought would be a simple event to post the Notes field of a Manual Test to the Log on step success. Based on the help files I attempted the following:
Sub GeneralEvents_OnStepSuccess(Sender, StepParams)
intStepID = StepParams.StepID
'Get the ManualTestingStepInfo Object
Set strTemp = Sender.GetStepInfo(intStepID)
'Get the data in Step notes and comments field
strTempNotes = strTemp.GetNotes()
'Outout the notes field to the log
Log.Message(strTempNotes)
End Sub
Unfortunately this results in an property or method not supported error at the "Set strTemp = Sender.GetStepInfo(intStepID)" line.
I've tried replacing "Sender" with "ManualTesting" as the help file seems to specify, but that results in an "Object required: 'ManualTesting' error.
What am I doing wrong?
Sub GeneralEvents_OnStepSuccess(Sender, StepParams)
intStepID = StepParams.StepID
'Get the ManualTestingStepInfo Object
Set strTemp = Sender.GetStepInfo(intStepID)
'Get the data in Step notes and comments field
strTempNotes = strTemp.GetNotes()
'Outout the notes field to the log
Log.Message(strTempNotes)
End Sub
Unfortunately this results in an property or method not supported error at the "Set strTemp = Sender.GetStepInfo(intStepID)" line.
I've tried replacing "Sender" with "ManualTesting" as the help file seems to specify, but that results in an "Object required: 'ManualTesting' error.
What am I doing wrong?
Hi Eero,
There are 2 ways to do this, depending on the way you run manual tests:
1. Add manual tests to the Test Items collection and run them from the collection. In this case, you can use the following approach:
Sub GeneralEvents_OnStepSuccess(Sender, StepParams)
Dim currentManualTestName, currentStep
currentManualTestName = Split(Project.TestItems.Current.ElementToBeRun.Caption, " - ")(1)
Set currentStep = Eval(currentManualTestName).GetStepInfo(StepParams.StepID)
Call Log.Message("The " & currentStep.GetCaption() & " step data", "Notes: " & currentStep.GetNotes())
End Sub
2. Run manual tests from script and use a global variable to hold a manual test's name. If you use this approach, your script can be as follows:
Dim currentManualTest
Sub RunManualTest
Dim manualTestName
manualTestName = "ManualTest1"
On Error Resume Next
Err.Clear()
Set currentManualTest = Eval(manualTestName)
If 0 <> Err.Number Then
Log.Error("The " & manualTestName & " manual test was not found")
On Error Goto 0
Exit Sub
End If
currentManualTest.Start()
End Sub
Sub GeneralEvents_OnStepSuccess(Sender, StepParams)
Dim currentStep
Set currentStep = currentManualTest.GetStepInfo(StepParams.StepID)
Call Log.Message("The " & currentStep.GetCaption() & " step data", "Notes: " & currentStep.GetNotes())
End Sub
I hope this helps.