cancel
Showing results for 
Search instead for 
Did you mean: 

OnStep Event

SOLVED
ebodien
Contributor

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?
1 ACCEPTED SOLUTION

Accepted Solutions
AlexanderM
Staff

RE: OnStep Event


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.
-----

Alexander
Customer Care Manager

View solution in original post

3 REPLIES 3
ebodien
Contributor

RE: OnStep Event

Ok, I've determined that I'm actually asking the wrong question.  The above will work when I supply the exact name of the manual script:



e.g. Set strTemp = TestName.GetStepInfo(intStepID). 



So the real question I have is how do I pass the test name into the Event.  I assume that the Sender object has the data, but I've been unable to determine the command needed to extract it, and the help files have not been helpful.


AlexanderM
Staff

RE: OnStep Event


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.
-----

Alexander
Customer Care Manager

View solution in original post

ebodien
Contributor

RE: OnStep Event

Thank you Alex.  I had implemented a solution similar to the second option using Project Variables, but I like the first option better as it seems like a lot less overhead.
New Here?
Join us and watch the welcome video:
Announcements