This is a migrated thread and some comments may be shown as answers.

XamlFindExpression and examples

1 Answer 143 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Stanislav
Top achievements
Rank 1
Stanislav asked on 19 Apr 2013, 06:59 AM
Hello Telerik,

Could you provide me with examples how I can use XamlFindExpression to boost elements identification in the window? I have faced with an issue when I want to find a button by its text content: .ByExpression(new XamlFindExpression(new string[2] { "XamlTag=Button", "TextContent=~Save" }));

But this expression returns null.

What is a XamlTagBase and how can I use it?
Can I specify exact tag index of the xaml tag order? How?
How can I use XamlPath? Is there any possibility to specify parent element in the search?

Can you provide me with more examples how I can use it more efficiently. Thank you.

Kind Regards,
Stanislav Hordiyenko

1 Answer, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 23 Apr 2013, 02:53 PM
Hello Stanislav,

1) Here is an example against our demo site:

FrameworkElement but = ActiveBrowser.SilverlightApps()[0].Find.ByExpression
 (new XamlFindExpression("xamltag=RadRadioButton", "Text = Radio Button"));
but.User.Click();

I am locating a RadRadioButton on the site with Text = "Radio Button". You don't need to use "new string[]".

Here is a video demonstration.

2) XamlTagBase is the XamlTag of the control which is extended. So if some element extends for example ListBoxItem its XamlBaseTag is ListBoxItem.

3) Here is an example for XamlTagIndex

FrameworkElement but = ActiveBrowser.SilverlightApps()[0].Find.ByExpression
               (new XamlFindExpression("TagIndex=button:0"));

4) You can use XamlPath again in the XamlFindExpression. Here I am locating the Header grid and then I am looking in it (parent) the button:

FrameworkElement header = ActiveBrowser.SilverlightApps()[0].Find.ByExpression (new XamlFindExpression("xamlpath=/grid[0]/grid[name=LayoutRoot]/frame[automationid=PART_ContentFrame]/contentpresenter[0]/singleexampleview[name=SingleExampleViewPage]/grid[name=LayoutRoot]/examplecontentcontrol[name=exampleContentControl]/grid[0]/contentpresenter[0]/headeredcontentcontrol[name=headeredContentControl]"));
             
            FrameworkElement but = ActiveBrowser.SilverlightApps()[0].Find.ByExpression(header, (new XamlFindExpression("xamlpath=/grid[0]/contentpresenter[0]/example[0]/grid[0]/stackpanel[0]/radradiobutton[0]")));
            but.User.Click();

Let me know if you need further assistance.
 

All the best,
Boyan Boev
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Stanislav
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
Share this question
or