TextBox and Label distinguishing

Ask general questions here.
atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

TextBox and Label distinguishing

Post by atom » Mon Feb 08, 2010 7:20 pm

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

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: TextBox and Label distinguishing

Post by Ciege » Mon Feb 08, 2010 7:31 pm

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.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Re: TextBox and Label distinguishing

Post by atom » Tue Feb 09, 2010 10:23 am

Hiya

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

Cheers

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

Re: TextBox and Label distinguishing

Post by Support Team » Tue Feb 09, 2010 10:41 am

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