Anyway to find only visible descendants?

Ranorex Spy, Recorder, and Studio.
fimo420
Posts: 55
Joined: Wed Jun 20, 2012 9:49 am

Anyway to find only visible descendants?

Post by fimo420 » Fri Oct 11, 2013 7:12 am

Hi,

Anyone know if there is anyway to find only the visible descendants on screen and not all descendants?

Swisside
Posts: 92
Joined: Thu Oct 10, 2013 10:40 am

Re: Anyway to find only visible descendants?

Post by Swisside » Fri Oct 11, 2013 8:25 am

Hello

Not sure about what you are asking but if I understood correctly you can use the "Visible" attribute.


Let's say I want all the visible buttons in the form titled "MyForm"

/form[@title='MyForm']/button[@visible='True']


Again not sure it's what you are asking.

Have a nice day

Boris
A simple thank you always does wonders !

fimo420
Posts: 55
Joined: Wed Jun 20, 2012 9:49 am

Re: Anyway to find only visible descendants?

Post by fimo420 » Fri Oct 11, 2013 9:22 am

Hi Boris,

Thanks for the reply.
I guess i wasnt clear enough.

Ex:
I wana find all the visible descendant object for one table, lets say of this specific table there are 20 buttons, but only 5 are visible on screen.
To get all the buttons i use :
IList <ButtonTag> buttonTags = repo.testWebsite.tdTable.FindDescendants<ButtonTag>();
What i wonder is can i somehow tell "FindDescendants" to only give me all visible buttons?
Reason for FindDescendants, is that for ex that table has several rows as chid and the buttons are inside the rows etc.

Is it possible to find the buttons from the table like you suggested?
ex: /form[@title='MyForm']/tdTable/button[@visible='True']??

/Feroz

Swisside
Posts: 92
Joined: Thu Oct 10, 2013 10:40 am

Re: Anyway to find only visible descendants?

Post by Swisside » Fri Oct 11, 2013 9:56 am

Okay now I get it :D

After looking a bit around I found this post http://www.ranorex.com/forum/identifyin ... t1280.html

The only argument you can pass in FindDescendants is (defaultlabel) which isn't explained that much in the documentation (http://www.ranorex.com/Documentation/Ra ... s__1_1.htm)

You could try using FindSingle for which you can use a RxPath as parameter :

http://www.ranorex.com/Documentation/Ra ... gle__1.htm

The RxPath synthax to target descendants is ".//" by the way.


Hope you can figure it out.


Boris
A simple thank you always does wonders !

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

Re: Anyway to find only visible descendants?

Post by Support Team » Fri Oct 11, 2013 2:34 pm

Hello,

Please try out the following code snippet below to get only visible buttons:
IList <ButtonTag> buttonTags = repo.testWebsite.tdTable.Find<ButtonTag>(".//button[@visible='True']");
IList<Button> btns = repo.Calculator.Self.Find<Button>(".//button[@visible='True']");
Regards,
Markus (T)
.
Image

fimo420
Posts: 55
Joined: Wed Jun 20, 2012 9:49 am

Re: Anyway to find only visible descendants?

Post by fimo420 » Mon Oct 14, 2013 9:14 am

Hi Markus,

It works with find :)
Can you tell me why it works with Find but not with FindDescendants?
Cause i thought it needed to be descendants, since the buttons are not direct children to the object.
The buttons are under Td\TR\Buttontags, but i have the TD in my repo item since there can be several TR.

Thanks for the help :)

/Feroz

Swisside
Posts: 92
Joined: Thu Oct 10, 2013 10:40 am

Re: Anyway to find only visible descendants?

Post by Swisside » Mon Oct 14, 2013 1:16 pm

Hey.

I explained the difference in my post above.


Have a nice day


Boris
A simple thank you always does wonders !

fimo420
Posts: 55
Joined: Wed Jun 20, 2012 9:49 am

Re: Anyway to find only visible descendants?

Post by fimo420 » Mon Oct 14, 2013 3:15 pm

Hi,

Sorry missed that part :(
Thanks Boris.