Page 1 of 1

Anyway to find only visible descendants?

Posted: Fri Oct 11, 2013 7:12 am
by fimo420
Hi,

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

Re: Anyway to find only visible descendants?

Posted: Fri Oct 11, 2013 8:25 am
by Swisside
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

Re: Anyway to find only visible descendants?

Posted: Fri Oct 11, 2013 9:22 am
by fimo420
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

Re: Anyway to find only visible descendants?

Posted: Fri Oct 11, 2013 9:56 am
by Swisside
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

Re: Anyway to find only visible descendants?

Posted: Fri Oct 11, 2013 2:34 pm
by Support Team
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)

Re: Anyway to find only visible descendants?

Posted: Mon Oct 14, 2013 9:14 am
by fimo420
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

Re: Anyway to find only visible descendants?

Posted: Mon Oct 14, 2013 1:16 pm
by Swisside
Hey.

I explained the difference in my post above.


Have a nice day


Boris

Re: Anyway to find only visible descendants?

Posted: Mon Oct 14, 2013 3:15 pm
by fimo420
Hi,

Sorry missed that part :(
Thanks Boris.