catch error then perform specific task
Hi,
during playback i get this error :
There was an attempt to perform an action at point (X, Y) which is transparent or out of the window bounds.
i know what is causing this error :
because my web page have scroll bar and test complete is trying to click on object with is hidden, if i manually drag the scroll bar to show the object, then the error is gone.
what i want to do :
i would like to catch this error by using an if,else script. If this error happen then i run a script to move the scroll bar
what i did :
i tried using 'try .. catch ..' but it does not work.
try { obj.click(); } catch (e) { Log.Error(e.description + "Specific Text"); //execute script here }
how can i catch the error and then perform a specific script to move the scroll bar ?
Hi,
Try/catch will not work because there is no JScript runtime error. Thus there is nothing to catch. The error posted is a 'logical' error posted by TestComplete. This kind of errors can be handled using the OnLogError event handler in TestComplete.
However, I would recommend to use the scrollIntoView() native web method to scroll the web object without interacting with scrollbars.
E.g.:
if (!obj.VisibleOnScreen)
{
obj.scrollIntoView(true); // small 's' because this is native name
if (!obj.VisibleOnScreen)
obj.scrollIntoView(false);
}
obj.Click(); // Capital C because this is TestComplete's method