Forum Discussion

sonia_reimelt's avatar
12 years ago

How does Try ... Catch work?





using TestComplete Version 9.31

KeywordTests with graphical user interface

testing web application





Hello,



I am new to TestComplete. I want to implement a test for a web page where I check wether an element is there or not. For some users this element is displayed, for some not. So I tried to use the Try ... Catch.



First idea: in the Try section: click on the link. When it does not work, it will go the catch section and everything is ok.

--> does not work. It throws an error and ignores that it is in a try section. I read the thread "How do I catch if an unexpected error occurs". It seems that this only works if I call a native method. That makes things much more complicated.



Second idea: OK, call a native method. So used the "Call Object Method". It sends a click event to the browser. It works fine when the link is there. Unfortunately when the link is not there, it throws an error and does not go to the catch section. The test fails although the link is not there.



My question: how do I program my test that it goes to the catch section?



Thanks,



   Sonia

1 Reply