Forum Discussion

Kamal_chennai's avatar
Kamal_chennai
Contributor
9 years ago

How to access Main Function Name in General Events

Hi,

 

I have to trigger General Events when Unexpected Window Occurs.

 

I have following Cases,

 Main Function

       Sub Function 1

       Sub Function 2

       Sub Function 3

 

Now the Main Function Call 3 Subfunctions, at the time Unexpected window appear while running on  Sub Function 2 or Sub Function 3.

 

Sub GeneralEvents_OnUnexpectedWindow(Sender, Window, LogParams)

Window.Close

Application .Terminate

End Sub

 

After Terminating the Application I want to call the Main Function which is called the Failed Sub function. Is it possible to get the Function? How can I get the Failed function?

 

Thanks

Kamal

  • JuliaBernikova's avatar
    JuliaBernikova
    9 years ago

    Hello Kamal,

     

    Here is an example of a possible approach to the test execution flow when a single test is attempted several times if it fails. To see this sample in action, run the 'MyRunner' routine from the 'TestRunner' unit.

     

    Let me know if you have any questions about this example.

    • Kamal_chennai's avatar
      Kamal_chennai
      Contributor

      Hi

       

      Any update???

       

      Let consider the following function

       

      Function ValidateNotePadText()

       Call OpenNotepad()

       Call EnterValuesInNote() 

      End Function

       

      Now the Sub function EnterValuesInNote() Failed due to some reason. So the Main function also fail. Now I want to get the Main Function name ValidateNotePadText() via script 

       

      is it Possibe? If Yes then may i know the approach

       

      Thanks

      Kamal

      • AlexanderM's avatar
        AlexanderM
        Staff

        Hello Kamal,

         

        Looks like you are trying to implement a very sophisticated approach to the test recovery - re-running a function that failed. This is not going to be easy :) You'll need to take into account the following:

        • It's not good to re-run a test procedure from an event handler - you may get an infinite recursion, and a stack overflow error after many failed iterations.
        • You can't easily get the name of a function from an event handler. But I don't think this is what you need, actually.
        • Re-running a function is possible, but presumes that you will have a special runner function that will control the test flow - run your function, check if it failed, re-run it again, etc.

        Let me see if we can create a small POC for the approach you are trying to implement (at least, in the form I understand it)... We'll post an update into this thread later this week.