How to get all the text elements from container

Class library usage, coding and language questions.
kiran.pol
Posts: 12
Joined: Tue Oct 06, 2009 7:40 am

How to get all the text elements from container

Post by kiran.pol » Thu May 27, 2010 8:19 am

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

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

Re: How to get all the text elements from container

Post by Support Team » Thu May 27, 2010 11:08 am

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
.
Image

kiran.pol
Posts: 12
Joined: Tue Oct 06, 2009 7:40 am

Re: How to get all the text elements from container

Post by kiran.pol » Thu May 27, 2010 1:51 pm

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

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

Re: How to get all the text elements from container

Post by Support Team » Thu May 27, 2010 2:39 pm

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
.
Image

kiran.pol
Posts: 12
Joined: Tue Oct 06, 2009 7:40 am

Re: How to get all the text elements from container

Post by kiran.pol » Thu May 27, 2010 2:46 pm

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

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

Re: How to get all the text elements from container

Post by Support Team » Thu May 27, 2010 2:49 pm

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
.
Image