Forum Discussion

msap's avatar
msap
Frequent Contributor
6 years ago

expected errors

how can i avoid the error on the application and make the script to move in spite of some errors .

Example when I try to export I get this format error sometimes. how can i avoid this types of errors or other duplicate file errors and make my script to run .

2 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    Here's some information on handling unexpected windows:

    https://support.smartbear.com/articles/testcomplete/handling-unexpected-windows/

     

    If the errors are always in the same place, so not really "unexpected", then you can always insert code to directly handle them, such as checking for the text in the format error you mentioned and if it exists, then click OK or whatever will dismiss it and let you continue.

     

    This will make your script run, but it's usually better if you clean up what's causing the errors in the first place. For instance, duplicate file names can be handled by making a saved file have a unique name every time.  We can make suggestions for this clean up if you let us know what's going on with your errors.

     

     

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      If you were manually executing the test, what would you do to be able to continue your test?  

       

      I click on a button. 

      I observe that an error message is displayed.

      I act on the error.

      I continue my test.

       

       

      Now... translate that into code (the below is pseudo-code intended for illustration)

       

       

      myApp.buttonOK.Click();
      
      if (myApp.WaitAliasChild('errorWindow', 10000).Exists){
      
          myApp.errorWindow.buttonOK.Click();
      
      }

       

       

      This is just one example... it's going to depend upon the specifics of your application. Code your test to be "smart", to look for error messages, windows, etc., so they can be handled. However, if they are things that are undesirable (like a duplicate filename, or something like that) then that means you may need to redesign your automation to act differently to avoid those errors... OR, if they are actually bugs in your application... well, report them and have your developers fix them...