cancel
Showing results for 
Search instead for 
Did you mean: 

catch error then perform specific task

SOLVED
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
Community Hero

Re: catch error then perform specific task

This is because the type of error raised is not a code exception but an operation exception with the "click" action.  These are not caught by try/catch.

 

Suggestion.  In your code for doing the object click, before the click, do a check for VisibleOnScreen. If VisibleOnScreen is false, then call obj.scrollIntoView(true).  This will scroll the web page to the component before the click.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
9 REPLIES 9
Community Hero

Re: catch error then perform specific task

https://community.smartbear.com/t5/TestComplete-Mobile-Application/catch-error-then-perform-specific...

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members 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. Postings made by [Community Expert Group] members
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.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Community Hero

Re: catch error then perform specific task

This is because the type of error raised is not a code exception but an operation exception with the "click" action.  These are not caught by try/catch.

 

Suggestion.  In your code for doing the object click, before the click, do a check for VisibleOnScreen. If VisibleOnScreen is false, then call obj.scrollIntoView(true).  This will scroll the web page to the component before the click.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Occasional Contributor

Re: catch error then perform specific task

hi tristaanogre,

 

Thank you for your reply.

your suggestion work well for me

below is the code i use, which is actually from AlexKaras

 

if (!obj.VisibleOnScreen) {

    obj.scrollIntoView(true);

    if (!obj.VisibleOnScreen) {

        obj.scrollIntoView(false);
    }
}

obj.Click();
djt
Occasional Contributor

Re: catch error then perform specific task

I have the same issue but in a Windows app rather thana web page

 

Aliases.MyApp.HwndSource_MainWindow.MainWindow.m_NodeControl.ExpandItem(("|[2]"));
Aliases.MyApp.HwndSource_MainWindow.MainWindow.m_NodeControl.Refresh();
Aliases.MyApp.HwndSource_MainWindow.MainWindow.m_NodeControl.DblClickItem("|[2]|[0]");

 

The third line craters if the tree view is scroll off the screen so node 2 is not visible

 

I can't call is visible on the NodeControl as it always is

 

How do I ensure node 2 is visible ?

djt
Occasional Contributor

Re: catch error then perform specific task

Scratch the above - I just call collapse on each branch and it comes into view

Community Hero

Re: catch error then perform specific task

Alternatively, you could check the VisibleOnScreen property.  If it is false, execute a page down or some other scroll event to bring the component to be visible on screen.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
djt
Occasional Contributor

Re: catch error then perform specific task

Yeah that didn't work cos the tree control is visible but that partcular node might not be so wasn't sure how to call is visible on a node?

Community Hero

Re: catch error then perform specific task

Hi,

 

.VisibleOnScreen is a generic property added by TestComplete to any valid object (i.e. that one with .Exists property been set to true) and thus can be checked regardless of whether or not the object is visible on the screen:

if (<control>.VisibleOnScreen)

  ...

else

  ...

 

Actually, for standard Windows controls, TestComplete puts them in view automatically if the control is out of view. So, in general, the

<parent>.m_NodeControl.DblClickItem("|[2]|[0]");

line should work without any tweaks.

But custom controls may not implement all required functionality and thus require either manual scrolling (like suggested by Robert) or some other actions to make control visible on screen (like you did).

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members 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. Postings made by [Community Expert Group] members
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.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Regular Contributor

Re: catch error then perform specific task

Hi Alex

 

I really appreciate your insight. I have learned a lot from experienced people like you here. Thank you! Smiley Happy

 

Dave

New Here?
Join us and watch the welcome video:
API Testing Mistake #2
APITestingMistake#2
Top Kudoed Authors