Forum Discussion

sarya's avatar
sarya
Frequent Contributor
13 years ago

Test execution pauses during nightly runs when exception occurs

Hi,



I have a query regarding a functionality.Whenever we run tests,sometimes some page is not opened in time or an object is not found,then the execution stops in between .During nightly runs ,if someone is not there to look at the test execution,it keeps sitting there and pauses the execution.Can we have something better function or option where we can say continue with next test or ignore the error and move on ,but that being automatic and not waiting for someone to drive that option. That can save a lot of time on running the tests as nightly runs take so long to run when error is encountered and it waits someone to say "Yes to execution".



Thanks,

Sumedha

5 Replies

  • Hi Sumedha,



    First of all, I recommend that you disable the "stop on error" option to prevent TestComplete from stopping test execution when an error occurs (see the Stopping Tests on Errors and Exceptions help topic for more information). After that, you'll be able to stop the current test item's execution via implementing an event handler for the OnLogError event and handling the specific error message. If an error message which is going to be posted to the test log contains a specific string (e.g. "object not found"), you'll need to call the Runner.Stop method and pass true as the method's argument.
  • sarya's avatar
    sarya
    Frequent Contributor
    Hi Allen,



    I have an example script code below:



    page1 = iexplore.Page("http://" + servername + ":" + port + "/" + r2wcontext + "/" + "pageMartViewer.do*");

    if (page1.document.all.Item("infoMessageDiv").outerText == "The document has no annotations. ")

       Log.Message("The annotation is deleted correctly by the user having manage annotations permissions","",pmNormal,Attr)

    else

       Log.Error("There is some error in creating the annotation","",pmNormal,Attr);



    I have also attached the error log screenshot. So when it does not find the page object "page1",it continues on error but the execution ends at the line where if loops starts and the corresponding error line in log says "Exception", I have both the options disabled "Stop on error" and "Error Dialog". So why does it stops at the loop saying exception in log ? If the options are disabled,it should continue to run the script .. It should take any exception as 'EXCEPTION' whether it is a loop code or anything else .



    Thanks,

    Sumedha

  • Hi Sumedha,



    "Object not found" errors are critical errors which must not be a normal part of your test execution. It looks like you just need to check whether the item in question exists before checking the item's text. Please see the Checking Whether an Object Exists help topic for more information.
  • rajendermehta's avatar
    rajendermehta
    Occasional Contributor
    Hello Sumedha and Allan,



    I have the similar issue:



    Story:

        I have a test senerio where I input the data file to process and check whether it passes or failed for particular file input execution.

        So, function look like: 



    function main()

    {

        //function call to get all files.



        foreach(file in files)

        {   

            function test(file)

                {

                      //Do processing.                  

                }    

        }

    }



    Problem:

        Now, for any particular instance, my test execution fails. I want my test should continue execution for next files input, indepedent of error occured in any particular itteration. Please guide, how to do that.



    Note:

    I have already handled the exceptions by try, catch block. I have already defined LogOnError event handler and runner.stop(true), but since it terminate my whole test execution.



    Best Regards,

    Rajender Mehta

    rajender_mehta@agilent.com

  • Hi Rajender,





    What is the text of the error message you get? Can it be catched via try..catch?