shankar_r wrote:
I tried the try/catch but it is not catching this error.
Yeah, I didn't think it would.
So, since "Click" doesn't have a return value, you're left with doing your detection elsewhere. Which, actually, is better automation anyways. Unless it is pertinent to the test case, you don't want to attempt an action unless you are sure that you CAN attempt the action. In the case of your error message, you need to make sure that the component you are clicking on is actually on screen and available for being clicked upon. This is part of the automation process itself and, therefore, should be taken into consideration when developing your automation code.
That said... the error you indicated usually means, to me, one of several things:
1) There are co-ordinates in your call to Click (e.g. MyObject.Click(20,5)). It is possible that the component in question has changed in size so that whatever co-ordinates are passed in are no longer valid. When making calls to "Click" or "ClickButton", I tend to prefer to leave the co-ordinates out. This has the default of clicking in the center of the component every time without needing to worry about the dimensions of the component.
2) The component in question is somehow not present within the viewing range of the screen. It could be that you need to execute some sort of "scroll" action on your application to make it available. This is especially true in some web applications or with some desktop components that scroll within a form.
3) The resolution of the machine one which the playback occurs is insufficient to fully display the application under test. This is a slightly bigger problem in that the environment on playback is different than the environment on development... or, for that matter, the environment on playback is out of scope based upon the requirements of the application under test. If the application undertest is developed expecting at least an 800 x 600 screen resolution and you're only running at 400X250 or something, then that's a problem with the environment.
There could be other factors but these are the things that I would look at to solve your problem that may not require any kind of "return" value on "click". If, however, you are expecting "Click" to work 100% of the time, you are left with 2 things: 1) You've discovered a bug in your application that the component is not presented properly to the end user or 2) You've discovered a bug in your automation where you are not properly detecting and adjusting the positioning of your components before you attempt an action.