I trid the following and it didn't work:
5 Answers, 1 is accepted
I did a bit of research on this. In your intended relative Xpath name=LayoutRoot refers to a name attribute, correct. In Xpath you need to use the '@' to denote an attribute. name=LayoutRoot looks for a child element with a tagName of "LayoutRoot". Also grid does not seem to be a valid tagName for an element. Highlight the intended element and check it out in the DOM explorer:
You need to determine the correct tagName. Here's an example:
The following page contains a grid:
When we check out the grid in the DOM Explorer we can see it's actually a div element with an id of "RadGrid1". The relative Xpath to reach that element looks like this:
So most likely your Xpath expression should mostly likely be rewritten like this:
the Telerik team
Can we use double slash("//") like we use in Xpath to traverse the Silverlight elements in depth:
no, you won't be able to use "\\" in XamlPath.
And XamlPath needs to follow a liner path. You have to traverse all nodes that lead up to a specific child element. It's best to combine XamlPath with a different Find Logic that gets you to the desired "starting" point, so to say.
For instance if you're looking for the first cell in a Grid named "MyGrid" here's what the Find Expression might look like:
We use the first part of the statement to get to the appropriate reference node. From there we use XamlPath to point to a specific element from its children.
I hope this helps.
the Telerik team
Test Studio Trainings
How can we access parent and grand parents(anywhere upwards) using xamlpath?
If you already have the XamlPath of the current element, like for example
You can easily find the XamlPath of the parent element:
and the grand parent will be:
As my colleague, Stoich, wrote on his previous post, XamlPath follows a liner path and you can use it to go backwards just following the "/" signs.
You might also find this article about DOM navigation very useful. You will find there how to navigate to other elements relative to the current element.
Hope this helps.