Check whether a button is hidden behind another window

Ranorex Spy, Recorder, and Studio.
uhmdown
Posts: 54
Joined: Mon Apr 03, 2017 12:00 pm

Check whether a button is hidden behind another window

Post by uhmdown » Tue Jul 18, 2017 9:00 am

Ranorex has a method "EnsureVisible" that brings an element to the front or scrolls it into view, so that automation script can perform a click on it afterwards.

But what if you just want to check whether an item is covered by another window?
The "Visible" property returns true even if the item is covered up by another window, so I can't use that.

This is a pretty basic scenario, so Ranorex must have some kind of method that does this out-of-the-box, that I haven't been able to find.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3949
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Check whether a button is hidden behind another window

Post by odklizec » Tue Jul 18, 2017 10:30 am

Hi,

I'm afraid, there is no out-of-the-box solution for this kind of issue. At least I don't know any. Honestly, I'm automating apps (either desktop or web based) with Ranorex for about 5 years, and I've never run into this kind of issue, so from my personal perspective, it's not so common problem? ;)

In case of individual app, you may be able to detect if the app is under another with "Active" attribute. Application covered by another application has Active attribute set to False. In case of individual elements, within the same app, I'm honest not quite sure how to detect their visibility? I would suggest to examine the element in question (in both states...covered/not covered) with Ranorex spy and check its Overview and Advanced attributes. Maybe there is an advanced attribute showing the visibility/coverage status? I think the Activate attribute could be evaluated even within the same app. You will just have to evaluate it on Form level and not particular UI element (like button). But it's hard to say without seeing your app and exact scenario.

In my opinion, if the element is fully covered by another element, its Visible attribute should be set to False. If it's not, then it's most probably an AUT fault? I mean, the AUT probably does not set correct Visibility state for given element?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

jma
Posts: 111
Joined: Fri Jul 03, 2015 9:18 am

Re: Check whether a button is hidden behind another window

Post by jma » Wed Jul 19, 2017 12:42 pm

Hi,

What the Visible-state means in Ranorex was already discussed at stackoverflow: https://stackoverflow.com/questions/379 ... ex-exactly

uhmdown
Posts: 54
Joined: Mon Apr 03, 2017 12:00 pm

Re: Check whether a button is hidden behind another window

Post by uhmdown » Wed Aug 02, 2017 1:12 pm

Just wanted to post the solution here, after some testing with a Ranorex Supporter:

Call Focus on the element.
Then check its "HasFocus" attribute.

If "HasFocus" is still false, then its because there's another window that is modal and blocking the element from getting focus.


Sounds obvious now, but we had to find the right combination of methods and attributes before stumbling across this one.