Page 1 of 1

Strange xPath for text field

Posted: Tue Mar 29, 2011 6:12 pm
by slavikf
In my application, i have one dialog box:
screenShot.png
I need to verify value of that text boxes.

So, used Recording Validation, but xPath for that text boxes are like this:

Code: Select all

/form[@title='Measurements']/container[@caption='ONH']/text[@caption='2.037']
Question:
- Why xPath use value of text box to identify it? It is clearly wrong, because it will always change, and its identification will fail.
- How else i can identify that component?

Attaching that dialog's Snapshot:

Re: Strange xPath for text field

Posted: Tue Mar 29, 2011 6:19 pm
by slavikf
Here is Spy screenshot with details of that text box:
Untitled.png
What is ControlId and how reliable is it for identification?

Re: Strange xPath for text field

Posted: Tue Mar 29, 2011 6:27 pm
by ekrell
Looking at the snapshot, you could use either controlID or Instance to identify the text although you should probably restart the application several times and make sure that whichever you use remains constant. (Try starting it with more programs running or less and see if anything changes).

I'm not sure what ControlID is but I recall hearing that it changes sometimes so it might not be reliable. I would suggest using Instance unless that changes when the application is restarted.

Edward

Re: Strange xPath for text field

Posted: Tue Mar 29, 2011 6:37 pm
by Support Team
If its an MFC app its probably best to use the control ID (as Edward said if it doesnt change after a restart),
otherwise use instance & classname.

If you prefer to use controlid automatically for all "Static" (= win32 label) classes you can use the following weight rule (just paste it into the weight rule list):

<rule name="Win32CaptionById" enabled="False" capability="nativewindow" attribute="controlid" setweight="111" conditionsoperator="or">
<condition source="self" attribute="class" match="^Static$" negate="False"/>
</rule>

Michael
Ranorex Team

Re: Strange xPath for text field

Posted: Tue Mar 29, 2011 6:41 pm
by slavikf
Where do i found ClassName for it?
And where do i look for "weight rule list"?

Re: Strange xPath for text field

Posted: Tue Mar 29, 2011 7:05 pm
by ekrell
The weight rule list is reached by clicking the link at the bottom of the "overview" tab in the spy, the link reads "Edit Path Weights...".

I'm just guessing but I think the ClassName is the 'Class' identifier (which is Static for the text).

Edward

Re: Strange xPath for text field

Posted: Tue Mar 29, 2011 7:07 pm
by Support Team
I am referring to the "class" attribute which in your case is "Static" (this is the class name for a Windows label)
You can open the Weight Rules editor in Settings/General/Edit Path Weights where you can tweak weights for path generation

Just copy the XML snippet and paste it into the list on the left side (basically tells Ranorex to use controlid for "Static" instead of caption); You can enable/disable the rule with the checkbox.

Michael