In test complete I am trying to use a try-catch block to see if a message box has an okay button and then click the okay button without crashing. I put the click operation inside a try block so if it fails the catch block can deal with the error, but it is crashing inside the try block. Here's an example:
try
{
okayButton = SomeLocation;
okayButton.click();
}
catch(err)
{
do something;
}
I would think that when Test Complete can't click the okay button, it would move into the catch block. However, I get an error on the okayButton.click(); line, which stops the test run. It says "there was an attempt to preform an action on a zero-sized window.". Does anyone know how do deal with this? Thanks in advance.
If
okayButton.click();
does notthrow
anerr
, Yourcatch
block will never be executed. You should validate that whenokayButton.click();
fails, it throws the error yourcatch
block is expecting.It may be that
okayButton.click();
is returning the error instead of throwing it.