Page 1 of 1

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

Posted: Wed Mar 04, 2009 5:34 pm
by AutoTester
Hi

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.

Thanks

Posted: Thu Mar 05, 2009 9:58 am
by Support Team
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 ...).

Regards,
Alex
Ranorex Support Team