control visible or not

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
rohitjain3333
Posts: 20
Joined: Tue Sep 20, 2011 7:12 am

control visible or not

Post by rohitjain3333 » Tue Jul 10, 2012 10:44 am

Hi,

We want to write a function which will take argument as ranorx path or any element and it will show that the element is visible or not. If the control is visible then it will return true else it will wait for 60 secs and will again check the element visibility and will return false. we are not getting how to send the element as argument to a function. Every time the element will be different.

Please help :roll: :cry:

Thank You in Advance

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: control visible or not

Post by Support Team » Wed Jul 11, 2012 1:53 pm

Hi,

Do you want to create a method which gets an element as argument and checks if that element is visible?
Which elements do you want to send to the function?
Did you try to define the argument as Adapter or Element?
Did you know that you can also add the visible attribute to the used RxPath, like "yourElement[... and @visible='true']"?

Regards,
Markus
Ranorex Support Team
.
Image

sham526
Posts: 34
Joined: Wed Jul 07, 2010 7:12 am
Location: Hyderabad(INDIA)

Re: control visible or not

Post by sham526 » Thu Jul 12, 2012 6:32 am

First the argument must be declared as ranorex.unknown type instead of Ranorex.Table or something like that
and the function can be
Public Function FnElement_Visibility_Check(rxpath as Ranorex.Unknown) As Boolean
************
****************
End Function

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: control visible or not

Post by Support Team » Thu Jul 12, 2012 3:58 pm

Hi,

I would say Adapter is more suitable for the argument.
Here is my suggestion ;):
Form form = "/form[@title='Calculator']";
        Button button = "/form[@title='Calculator']/titlebar/button[@accessiblename='Close']";
        checkVisibility(form);
        checkVisibility(button);
}
        
        
public void checkVisibility(Ranorex.Adapter adap){
        	
        Report.Info(adap.Visible.ToString());
}
Thanks for posting your method!

Regards,
Markus
Ranorex Support Team
.
Image

dman
Posts: 64
Joined: Mon Aug 29, 2011 9:33 am
Location: München

Re: control visible or not

Post by dman » Thu Sep 20, 2012 10:19 am

annoying that the Visible attribute is not properly delivered - the elements I'm checking are not visible at all, yet the Spy "sais" they are and hence I get "nice" false negatives

not to mention that using the Adapter approach (your example) does not work in my case as I work with generic Ranorex.Core.Element objects and can't quite make the conversion

any idea how I can get the real Visible attribute value?

All the best,
D.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: control visible or not

Post by Support Team » Thu Sep 20, 2012 5:07 pm

Hi,

In order to analyze the issue we would need a Ranorex snapshot file of the specific element.
Following link will show you how to generate a snapshot file:
Creating Ranorex Snapshot Files

Thanks,
Markus
Ranorex Support Team
.
Image

dman
Posts: 64
Joined: Mon Aug 29, 2011 9:33 am
Location: München

Re: control visible or not

Post by dman » Fri Sep 21, 2012 9:34 am

Hi Markus,

As background, the element is contained on the login page of the AUT which (as it should) is not visible anymore after login - but I still get all the elements as visible.

Please find attached the snapshot of the element (container with all login elements). It is taken after login - hence when it should be recognized as invisible.

All the best,
D.
Attachments
LoginPageElements.rxsnp
Login page elements (snapshot after login)
(330.42 KiB) Downloaded 237 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: control visible or not

Post by Support Team » Fri Sep 21, 2012 5:18 pm

Hello,

Thank you for the Snapshot file.
It seems that the loginForm still exists at this time. Can you please send us a snapshot file from the whole application? We will look into this issue and get back to you as soon as possible.

Regards,
Bernhard
Ranorex Support Team
.
Image

dman
Posts: 64
Joined: Mon Aug 29, 2011 9:33 am
Location: München

Re: control visible or not

Post by dman » Mon Sep 24, 2012 9:01 am

Hi Bernhard,

True, the form still exists but after login is not visible anymore.
I'll send you the snapshot via e-mail (I'll include a link to this post).

All the best.
D.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: control visible or not

Post by Support Team » Mon Sep 24, 2012 2:06 pm

Hi,

Thanks for the snapshot!
Is the "Visible" attribute of that element "/dom[@caption='RTT PictureBook']//div[#'flashContainer']/flexobject/container/container/element[@id='loginStage']" always false or just when the login page is hidden?
If it is not always false you can use this element in order to check if the login page is visible or not.

Regards,
Markus
Ranorex Support Team
.
Image

dman
Posts: 64
Joined: Mon Aug 29, 2011 9:33 am
Location: München

Re: control visible or not

Post by dman » Mon Sep 24, 2012 4:15 pm

ha, you have a good eye :) that is part of a workaround I've asked dev to implement (yes I can use it); but my problem is that from now on I will not be able to trust Ranorex's results 100% anymore, as I would expect that a hidden element is also reported as hidden/not visible :(

All the best,
D.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: control visible or not

Post by Support Team » Wed Sep 26, 2012 3:13 pm

Hi,

Thanks ;).

We are doing our best to determine if an element is visible or not but for some special controls it is not always possible as they seem to be visible and it is also often returned that they are visible although they are not shown.

Regards,
Markus
Ranorex Support Team
.
Image

CThees
Posts: 3
Joined: Wed Jul 30, 2014 10:54 am

Re: control visible or not

Post by CThees » Mon Sep 01, 2014 1:46 pm

Hello everybody,

I have a similar case, I guess. I have a link which is displayed or not, depending on the state of the application. I want to check if the link is shown before I try to click it. The View Spy identifies the visibility of the element correctly when trying to highlight it while it is not visible. The error message states: "The item exists but could not be highlighted because it could not be made visible."

That message made me assume that a call of "EnsureVisible()" on that element in this state would also return false. Sadly, it does not. Any idea why? Was I thinking wrong?

Regards,
Clemens

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: control visible or not

Post by Support Team » Wed Sep 03, 2014 5:57 pm

Hi Clemens,

The highlight functionality and the EnsureVisible method work in a different way. To be able to highlight an element it really needs to be visible for the user. When you execute the EnsureVisible method Ranorex "tries" to bring it in the visible area, that it is no longer hidden, when Ranorex was able to bring it to the visible area, even though it is actually still invisible for the user, the action returns true since it would be visible in case the application changes its visible state because it is in the visible area.

To check if an element is visible or not you should be able to use the visible attribute. You could for instance also add the visible attribute ([@name='...' and @visible='true']) to the RxPath of the link to ensure Ranorex just clicks the element when it is visible.

Regards,
Markus
.
Image