Is there a way of getting the text based on a class type

Ask general questions here.
Posts: 6
Joined: Fri Feb 20, 2009 11:26 am

Is there a way of getting the text based on a class type

Post by AutoTester » Wed Mar 04, 2009 5:34 pm


Ranorex gets all the text (Static and Edit). Is there a function to get the text by the class name it belongs to?

I can get the class name for a particular text, but is there a function like FindDescendants but by the class name say Edit. The idea is to find all the Editboxes in a form.


User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA

Post by Support Team » Thu Mar 05, 2009 9:58 am

You can use the Find method with a relative path that searches for a classname, e.g.:

Code: Select all

Form form  = ...;
IList<Text> descendantEdits = form.Find<Text>(".//text[@class='Edit']");
Using RanoreXPaths you can search for elements matching any of the attributes listed in RanorexSpy. E.g. you could search for all elements that have a 'Text' attribute with value "Hello World":

Code: Select all

IList<Unknown> elements = Host.Local.Find<Unknown>("//*[@text='Hello World']");
The '*' means "match all roles/capabilites" (e.g. Form, Button, Text, or ...).

Ranorex Support Team