Page 1 of 1

TextBox and Label distinguishing

Posted: Mon Feb 08, 2010 7:20 pm
by atom
Hiya

A Label and a TextBox both seem to get mapped to Ranorex.Text
However it seems the Caption property is only there for Label's, and not TextBoxes

Im looking for the RxPath to select only TextBoxes
The following doesnt seem to work (xpath error):

myForm.Find(of ranorex.text)("descendant::text[@Caption string-length()>0]")

any idea how i can do that?

Thanks

Re: TextBox and Label distinguishing

Posted: Mon Feb 08, 2010 7:31 pm
by Ciege
In my AUT, while both Labels and TextBoxes are of type Ranorex.text, the ControlType & ControlTypeName is different for each.
Labels
ControlType = System.Windows.Forms.Label
ControlTypeName = Label
TextBoxes
ControlType = System.Windows.Forms.TextBox
ControlTypeName = TextBox

So you should be able to query off of one of thos attributes.

Re: TextBox and Label distinguishing

Posted: Tue Feb 09, 2010 10:23 am
by atom
Hiya

Unfortunately this property is only for UI Automation elements, mine are MFC !

Cheers

Re: TextBox and Label distinguishing

Posted: Tue Feb 09, 2010 10:41 am
by Support Team
atom wrote:myForm.Find(of ranorex.text)("descendant::text[@Caption string-length()>0]")
There is no "string-length" operation in RanoreXPath, but you can use "not equals" operator (!=) to check for non-empty strings:
myForm.Find(of ranorex.text)("descendant::text[@Caption!='']")
Ranorex.Text "Caption" vs "Text" attribute:
In general, the "Caption" attribute is only set for static text controls like labels, the "Text" attribute is set for every element with Role Ranorex.Text. What is considered a static text control may differ by technology, but these are the standard rules for all technologies.
Ciege wrote:ControlType & ControlTypeName
These attributes are only available for .NET System Windows Forms controls.
atom wrote:Unfortunately this property is only for UI Automation elements, mine are MFC!
You can use the "class" ("NativeWindow" capability) or the "Role" ("Accessible" capability) attribut to distinguish static and non-static text controls in MFC applications.

Regards,
Alex
Ranorex Support Team