Spy doesn't detect the element type.

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
Posts: 2
Joined: Mon Jan 10, 2011 3:29 am

Spy doesn't detect the element type.

Post by chandrask » Mon Jan 10, 2011 4:48 am

I am testing a Silverlight app. The app has a button with an icon and text within it using data templates. The buttons are created dynamically in a stackpanel and therefore doesn't have any unique id. But the text within everybutton is unique.

I am following the Ron's approach in his RanorexPath screencast. To identify such buttons uniquely the path i am using is "button/text[@caption='Blue']/..". The path when typed in the spy detects the control properly inthe app. When the control is added to the repository, the element shows up as unknown element and not as button. When i append "/button" to the path, the repository marks it as Button element, but the spy doesn't detect the control in the UI and denotes the path as incorrect.

I need to store the element as Button in the repo, so i can invoke the button events from the code behind. When the button is of unknown type, the code behind doesn't allow type casting to Button. How to store the element as button in the repo and still be able to detect the control using spy? An example xpath would help a lot. Thanks!

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA

Re: Spy doesn't detect the element type.

Post by Support Team » Mon Jan 10, 2011 11:09 am

You almost had it :)
All you need to do is modify the path you were trying, from "button/text[@caption='Blue']/.." to "button/text[@caption='Blue']/parent::button". By appending the "/button" to the path you were saying look in the parent of the text (which is the button) for a child button which does not exist. The path you had ("button/text[@caption='Blue']/..") says find a button that has a child text element where the caption is equal to 'blue' and then find the parent of the text element. The new path ("button/text[@caption='Blue']/parent::button") says the same thing but qualifies the parent as a button.

Also, you might find the section on the RanoreXPath and UI adapters in the user guide useful:
http://www.ranorex.com/support/user-gui ... xpath.html
http://www.ranorex.com/support/user-gui ... apter.html

Ranorex Team