Forum Discussion

tmahender12's avatar
tmahender12
Frequent Contributor
10 years ago

Event Handling

I created unexpected window event handler, now how to call that event handler, when error comes will it be automatically called?

  • NisHera's avatar
    NisHera
    Valued Contributor

    Easy way of handling unexpected windows are from project properties see attachment 

     

    if you are using event handler you have to wite what to be dome when event fired..

    this is an example I'm using

    function Events_OnUnexpectedWindow(Sender, Window, LogParams){
    var ErrMsg;
      LogParams.Locked = true; //not to post error message
      ErrMsg = 'the unexpected window is  '+ Window.Name;
      Log.Message(ErrMsg);
      Log.Picture(Sys.Desktop.ActiveWindow());
      if (Aliases.myApp.dlgWarning.OK.WaitProperty("Exists",true, 700)) {
        Aliases.myApp.dlgWarning.OK.ClickButton();
        return;
      }
      if (Aliases.myApp.dlgInformation.OK.WaitProperty("Exists",true, 700)) {
        Aliases.myApp.dlgInformation.OK.ClickButton();
        return;
      }
      if (Aliases.myApp.ConfirmDlg.Yes.WaitProperty("Exists",true, 700)) {
        Aliases.myApp.ConfirmDlg.Yes.ClickButton();
        return;
      }
      if (Aliases.myApp.ErrorDlg.OK.WaitProperty('Exists',true, 500)) {
        Aliases.myApp.ErrorDlg.OK.ClickButton();
        Runner.Stop(true);
      }
    }
    • tmahender12's avatar
      tmahender12
      Frequent Contributor

      thanks for your reply, my application connects to cloud, if there is any network error it throws error saying "couldnot connect,Contact it support"

      when iam executing the tests, the execution pauses at when the window comes, even though i wrote event handler like this, the excution does not goes to  event handler

       

      sub Events_OnUnexpectedWindow(Sender, Window, LogParams){
      sys.process.Activatewindow
      sys.window(client*).terminate()
      }

      do i need to explicitly call the event handler, just if i write event handler is sufficeint? 

      • NisHera's avatar
        NisHera
        Valued Contributor

        wht do you get when you click view button in event page..?

        that is where you hv to wright the handler

        picture attached