Strange xPath for text field : Object Identification and Technologies

Strange xPath for text field

Technology specific object identification, supported applications, web technologies, and 3rd party controls.

Strange xPath for text field

Postby slavikf » Tue Mar 29, 2011 7:12 pm

In my application, i have one dialog box:
screenShot.png
screenShot.png (30.23 KiB) Viewed 207 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 12 times
User avatar
slavikf
 
Posts: 97
Joined: Mon Sep 13, 2010 10:07 pm
Location: Toronto, Canada

Re: Strange xPath for text field

Postby slavikf » Tue Mar 29, 2011 7:19 pm

Here is Spy screenshot with details of that text box:
Untitled.png
Untitled.png (11.52 KiB) Viewed 205 times

What is ControlId and how reliable is it for identification?
User avatar
slavikf
 
Posts: 97
Joined: Mon Sep 13, 2010 10:07 pm
Location: Toronto, Canada

Re: Strange xPath for text field

Postby ekrell » Tue Mar 29, 2011 7: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
ekrell
 
Posts: 10
Joined: Thu Dec 02, 2010 8:16 pm

Re: Strange xPath for text field

Postby Support Team » Tue Mar 29, 2011 7: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
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: Strange xPath for text field

Postby slavikf » Tue Mar 29, 2011 7:41 pm

Where do i found ClassName for it?
And where do i look for "weight rule list"?
User avatar
slavikf
 
Posts: 97
Joined: Mon Sep 13, 2010 10:07 pm
Location: Toronto, Canada

Re: Strange xPath for text field

Postby ekrell » Tue Mar 29, 2011 8: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
ekrell
 
Posts: 10
Joined: Thu Dec 02, 2010 8:16 pm

Re: Strange xPath for text field

Postby Support Team » Tue Mar 29, 2011 8: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
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to Object Identification and Technologies

Who is online

Users browsing this forum: No registered users and 0 guests