Clicking an element obscured behind other elements

Ranorex Studio, Spy, Recorder, and Driver.
BruceBalen
Posts: 9
Joined: Thu Jun 18, 2009 9:57 pm

Clicking an element obscured behind other elements

Post by BruceBalen » Thu Jun 18, 2009 10:23 pm

Hi all,

I hope someone here has had experience with this problem. Here's the story:

I have a program that is doing a lot of clicking on text elements in a web form. After a certain point, the list containing these elements gets long and starts to scroll upward. This means that some elements near the top scroll up under objects above, becoming obscured from view.
The problem comes when i have a click command that is meant to click one of the elements which has been obscured. Ranorex "finds" and "clicks" this element, and thinks it has done so successfully. In reality, the element being clicked is behind another object on the form (or even behind some browser buttons!) and the "click" effectively clicks the object which is obscuring the intended target. As you can imagine, this has very unintended and very problematic consequences when Ranorex starts clicking refresh buttons in the host browser window, etc.

Here is a visual representation as best as I can manage in text.

Intent/What Ranorex thinks it's doing:
MOUSE --(click)--> TARGET

Actual result:
MOUSE --(click)--> [OBJECT]TARGET

Essentially, Ranorex doesn't even see the obscuring object (in [ ]) and clicks where the target should be (and actually is, but so is the obscuring object).

I tried a workaround like try clicking, or catch and scroll the list to reveal the target, but Ranorex never fails the try and continues on like nothing happened.
Is there any way that Ranorex knows an element is actually behind another element/object?

Please help. I need to have this solution ready by end of week if at all possible!

Thanks in advance,
Bruce

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Clicking an element obscured behind other elements

Post by Ciege » Thu Jun 18, 2009 11:47 pm

Well, my first question is how does a user do it manually? Is it possible for a user to click an object behind another object? If there is a user workaround, try mimicking that functionality... If not sounds like a poor design from development.

You can try some of the following...

1) Get the .Visible property of the object before clicking on it. If .Visible = false, you know you need to do something.

2) Try the Ranorex method EnsureVisible(). Although I do not know if this will work for you.

3) Use the DOM. get the DOM object yourself and issue the .click method. Problem here is if there is an event fired on the click when it manually happens. If so you will need to also issue the fire event on the object yourself.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

BruceBalen
Posts: 9
Joined: Thu Jun 18, 2009 9:57 pm

Re: Clicking an element obscured behind other elements

Post by BruceBalen » Fri Jun 19, 2009 2:14 am

Ciege wrote:Well, my first question is how does a user do it manually? Is it possible for a user to click an object behind another object? If there is a user workaround, try mimicking that functionality... If not sounds like a poor design from development.
A user would scroll through the list until they bring the target back into view. I can't have Ranorex do this because it thinks it already sees the target element.
I can't tell Ranorex "If you don't see this element, scroll around until you do." It doesn't fail the "do I really see it" check.


You can try some of the following...

1) Get the .Visible property of the object before clicking on it. If .Visible = false, you know you need to do something.

2) Try the Ranorex method EnsureVisible(). Although I do not know if this will work for you.

I tried the .isVisible check and enabled .UseEnsureVisible = true for the target element, but Ranorex will never fail this check and keeps on working like it never happened.

3) Use the DOM. get the DOM object yourself and issue the .click method. Problem here is if there is an event fired on the click when it manually happens. If so you will need to also issue the fire event on the object yourself.

Actually, there is no event I need, it just has to be selected. This may be the way. I have some trouble navigating the guides here, so a link to the DOM material would be much appreciated.

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Clicking an element obscured behind other elements

Post by Ciege » Fri Jun 19, 2009 4:07 pm

Dom material lives throughout the web. I would suggest at least going to MSDN and reading up on the browser object and document object there.

You need to determine the type of object it is you want to click (I.e. is it an ATag link, etc...).

Once you get the DOM object of the browser you can search for the document object. Then again you can search for the object you want o interact with. Once you have that object you can call its click method and go from there.

You can try starting here: http://msdn.microsoft.com/en-us/library/ms531073.aspx or here: http://msdn.microsoft.com/en-us/library ... S.85).aspx
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Clicking an element obscured behind other elements

Post by Ciege » Fri Jun 19, 2009 4:12 pm

Forgot to mention... If you are using IE7, try downloading the IE Developer Toolbar. It has a DOM browser that you can browse for and inspect your DOM objects directly from IE. If you are using IE8, I believe the developer tools are already built in.

http://www.microsoft.com/Downloads/deta ... laylang=en
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

BruceBalen
Posts: 9
Joined: Thu Jun 18, 2009 9:57 pm

Re: Clicking an element obscured behind other elements

Post by BruceBalen » Fri Jun 19, 2009 8:46 pm

Thanks for all your help, Ciege. I was referring to any documentation on how Ranorex connects to DOM objects, but maybe that doesn't exist at the moment.
Anyhow, I've figured out a workaround for the moment by checking the screenRectangle.Location values for the target object before clicking it. If it falls outside the "clickable" area, I scroll it into view. This is kind of a hack and not too robust, but it lets me continue developing.

Now on to the next issue. There's always a next issue. :wink:

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Clicking an element obscured behind other elements

Post by Support Team » Mon Jun 22, 2009 2:27 pm

Bruce,

Are your textboxes obscured by other elements in the DOM or by controls outside the browser ?
Could you please post a screenshot or Ranorex Snapshot of your web site in question ?
(Alternatively you can also send it to [email protected])

Michael
Ranorex Team

BruceBalen
Posts: 9
Joined: Thu Jun 18, 2009 9:57 pm

Re: Clicking an element obscured behind other elements

Post by BruceBalen » Tue Jun 30, 2009 1:11 am

My workaround is working fine for my purposes and I'm already on to the next project. I should spend my time developing rather than pursuing this issue any further, so I'll have to let it rest for now. Thanks everyone for the help. :)