cancel
Showing results for 
Search instead for 
Did you mean: 

catch error then perform specific task

SOLVED
Highlighted
Occasional Contributor

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 ?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: catch error then perform specific task

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

 

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

3 REPLIES 3
Highlighted
Occasional Contributor

Re: catch error then perform specific task

sorry, i post it in a wrong category ..

it is suppose to be in web application .. but i don't know how to delete this ..

Highlighted
Community Hero

Re: catch error then perform specific task

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

 

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

Highlighted
Occasional Contributor

Re: catch error then perform specific task

Hi AlexKaras,

 

Thank you very much for your reply.

I use the code you provide and it work well for me, without any error.

 

New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges!

Challenge Status

Changing options from outside of TestComplete

Participate!

How to execute remote test and obtain results via Test Runner REST API

Participate!

Comparing content of HTML table with Excel file data

Participate!

Compare HTML table with Excel file and correct data in the file

Participate!
Top Kudoed Authors