Page 1 of 1

How to get all the text elements from container

Posted: Thu May 27, 2010 8:19 am
by kiran.pol
Hi,

There is a control of type container and it has sub elements of type text. i want to read the text value of each text in the container. How can i do this.

i tried using the following code but dose not work for me

Ranorex.Container IV_Add = <XPath of Container>
Element[] invadd=IV_Add.FindChildren(Role.Text);
for(int i=0; i<=invadd.Length; i=i+1)
{
Console.WriteLine(invadd.GetAttributeValue("Text"));
}

Thanks
Kiran pol

Re: How to get all the text elements from container

Posted: Thu May 27, 2010 11:08 am
by Support Team
Hi,

I would use following code to get all elements of type Ranorex.Text
Ranorex.Container cont = "yourPath";
foreach(Ranorex.Text txt in cont.FindChildren<Ranorex.Text>())
{
	Console.WriteLine(txt.TextValue);
}
Please also take a look to our tutorial
http://www.ranorex.com/Documentation/Ra ... torial.pdf

Regards,
Peter
Ranorex Support Team

Re: How to get all the text elements from container

Posted: Thu May 27, 2010 1:51 pm
by kiran.pol
Hi ,,

Thanks the code works fine but i have on more porblem .. I actually want to get the AccessiableName or AccessiableDescription property of the text element because the text associated with the child elements is empty .. i tried using

Console.WriteLine(txt.AccessiableDescription); but i suppose that is not the way it would work :(

Regards
Kiran Pol

Re: How to get all the text elements from container

Posted: Thu May 27, 2010 2:39 pm
by Support Team
Hi,

Please take a look to the API documentation of Ranorex.
http://www.ranorex.com/Documentation/Ra ... eValue.htm
Example Code:
Text.Element.GetAttributeValue("accessibledescription");
Regards,
Peter
Ranorex Support Team

Re: How to get all the text elements from container

Posted: Thu May 27, 2010 2:46 pm
by kiran.pol
Thanks a lot ... it works perfect..

I will go through the links you have provided to get better insight of things to use..

Thanks
Thanks
Kiran Pol

Re: How to get all the text elements from container

Posted: Thu May 27, 2010 2:49 pm
by Support Team
Hi,

Also take a look to our screen casts
http://www.ranorex.com/support/screencasts.html
The two about RxPath are really helpful and explain you the RxPath in more detail.

Regards,
Peter
Ranorex Support Team