XamlFindExpression and examples

2 posts, 0 answers
  1. Stanislav
    Stanislav avatar
    1 posts
    Member since:
    May 2012

    Posted 19 Apr 2013 Link to this post

    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
  2. Boyan Boev
    Boyan Boev avatar
    1072 posts

    Posted 23 Apr 2013 Link to this post

    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"));

    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]")));

    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
Back to Top