1

I am trying to incorporate into my Automation scripts functionality that will prevent the whole script from stopping when an Object Does Not Exist Error for a web object occurs. Instead the script should catch the error and perform a different function and continue running other scripts.

I first tried a Try Catch block, but then I learned it cannot see the errors generated by TestComplete itself. I looked into the Event Handlers you can make via the tool as well, but they don't seem to make any sense for the solution I need.

Here is an example and what I am trying to do.

function TestPage() {
\\Some condition where it will only continue if no errors are raised

   var testobj = Aliases.MappedName
   testobj.Click

   //more code

//goes here if an error occurs at any point
//executes a reset function.
1
  • Why isn't the response marked as an answer? For me it resolved this exact same issue - please note marking as answer will help others who have similar issue with us. Commented May 12, 2015 at 6:56

2 Answers 2

1

I can suggest two possible approaches that can be used separately or together.

  1. You can check an object for existence before trying to get it. When working with the Name Mapping tree, this can be done with help of the WaitAliasChild and WaitMappedChild methods. This method is the best if you know that an object can be missing at a specific test step.

  2. You can handle the OnLogError event in order to handle errors you want. Using this handler, you can prevent the error from being posted to the test log. Also, you can disable the Stop on error project option to prevent TestComplete from stopping the test on error and stops execution from within the OnLogError event handler using the Runner.Stop method. This approach works if you do not know at which exactly test step the issue can occur.

Personally I prefer the first approach and treat the second situation as an issue in my test or the tested application.

Sign up to request clarification or add additional context in comments.

Comments

0

I encountered a similar issue in my tasks, and after trying various approaches, I found a solution that works effectively:

Log.Enabled = false; // Disable logs temporarily
var check = YourObjectName.Exists; // Check if the object exists
Log.Enabled = true; // Re-enable logging

// Now, handle the existence check and logging manually
if (check) {
    Log.Checkpoint("Warning dialogue box appeared. Clicked on OK button.");
}

Disable logs temporarily to avoid printing when the object doesn't exist. Handle existence checks and logging manually with an if condition. This allows script continuation while logging errors when they occur.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.