How to handle known Object not found error and continue next line of script execution?

239 Views Asked by At

Tool : Squish Script : Python

How to handle known Object not found error and continue next line of script execution?

Tool : Squish Script : Python

How to handle known Object not found error and continue next line of script execution?

Expecting below: My test script execution stops = when object not found error : Script Error is shown. Further lines of script is not executed.

I need to continue the execution eventhough there is a object error which is known.

1

There are 1 best solutions below

0
1vonzhang On

You can simply use try-except block in Python.

try:
    waitForObject(objectName)
except LookupError:
    doSomethingElse()

continueExecution()

If you run Squish interactively, the execution by default still stops and shows a pop-up giving you a chance to Debug, Pick a new object or Throw an error. If you would expect the LookupError, there is a checkbox you can tick in the pop-up dialog to always throw an error without asking you. This behaviour can be reverted in IDE Edit->Preference->Squish->Playback, and (un)tick the option "Halt Test Execution in case of 'Object not found' issues for inspecting and fixing".