Forum Discussion

tmahender12's avatar
tmahender12
Frequent Contributor
9 years ago

How to write event for unexpected window

HI,

I am getting unepxcted network error...some times, do i wrote a unexpected window event handler as below, but its not working all the time, any improvement in the code?


Sub AssetsOnlineServerError_OnUnexpectedWindow(Sender, Window, LogParams)


aqutils.Delay(2000)
Log.Warning("Application is Going to terminate as Asset Online Server Occured")
Sys.Process("Client*").Terminate
Log.Warning("Application Terminated")
aqutils.Delay(1000)
Call ReturnToBaseState
Log.Warning("Application returned to Base State and ready for Next test case to execute")


End Sub

4 Replies

  • tmahender12's avatar
    tmahender12
    Frequent Contributor

    also what is the difference between Ovelappin window and Unexpected Window Event. when i keep both..my issue is getting solved

    • AlexKaras's avatar
      AlexKaras
      Champion Level 3

      Hi,

       

      Both OnOverlappingWindow and OnUnexpectedWindow events occur only when test code tries to interact with some UI element via the mouse or keyboard like the human user do. Events are not triggered if the test code just gets or sets some properies of the UI element. For example

      window.Caption = "My modified caption"

      line of code will never trigger these events because there is no interaction with the window here.

      OnUnexpectedWindow event is triggered when test code tries to interact with some target UI element and this element (or the point that test code tries to interact with) is blocked with some other window in a way that this target UI element can not be activated or focused. Usually, those blocking windows are system modal or application modal message boxes.

      As an example, if test code tries to execute

      window.editBox.Keys("Hello world")

      line of code which requires the window object to be activated (i.e. put in front of all other windows) and the editBox control to be focused, the OnUnexpectedWindow event will be triggered if the above actions cannot be performed because of system modal or application modal message box displayed.

      OnOverlappedWindow event is triggered when test code tries to interact with some target UI element and this element (or the point that test code tries to interact with) is overlapped with some other window or control but this overapping control is not a modal one, but just overlaps the target control.

      The baisc difference - in case of modal window, the blocked control cannot get focus until the blocking modal window is closed. In case of overlapping window - the blocked control can get focus without blocking window to be closed.

      Hope this makes things to be more clear...

      • tmahender12's avatar
        tmahender12
        Frequent Contributor

        thanks for your reply, but i could not click on the unexpected window using regular process, iam using Alt+F4 to close unexpected window, is there any other method for handling these windows