Strange xPath for text field

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
User avatar
slavikf
Posts: 104
Joined: Mon Sep 13, 2010 9:07 pm
Location: Toronto, Canada
Contact:

Strange xPath for text field

Post by slavikf » Tue Mar 29, 2011 6:12 pm

In my application, i have one dialog box:
screenShot.png
screenShot.png (30.23 KiB) Viewed 1218 times
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:
Attachments
Measurements.rxsnp
(108.51 KiB) Downloaded 204 times

User avatar
slavikf
Posts: 104
Joined: Mon Sep 13, 2010 9:07 pm
Location: Toronto, Canada
Contact:

Re: Strange xPath for text field

Post by slavikf » Tue Mar 29, 2011 6:19 pm

Here is Spy screenshot with details of that text box:
Untitled.png
Untitled.png (11.52 KiB) Viewed 1216 times
What is ControlId and how reliable is it for identification?

ekrell
Posts: 10
Joined: Thu Dec 02, 2010 7:16 pm

Re: Strange xPath for text field

Post by ekrell » Tue Mar 29, 2011 6:27 pm

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

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

Re: Strange xPath for text field

Post by Support Team » Tue Mar 29, 2011 6:37 pm

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

User avatar
slavikf
Posts: 104
Joined: Mon Sep 13, 2010 9:07 pm
Location: Toronto, Canada
Contact:

Re: Strange xPath for text field

Post by slavikf » Tue Mar 29, 2011 6:41 pm

Where do i found ClassName for it?
And where do i look for "weight rule list"?

ekrell
Posts: 10
Joined: Thu Dec 02, 2010 7:16 pm

Re: Strange xPath for text field

Post by ekrell » Tue Mar 29, 2011 7:05 pm

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

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

Re: Strange xPath for text field

Post by Support Team » Tue Mar 29, 2011 7:07 pm

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