Help about XamlFindExpression

6 posts, 0 answers
  1. Yogesh
    Yogesh avatar
    11 posts
    Member since:
    Jan 2011

    Posted 11 Jan 2011 Link to this post

    I am using WEBAii framework to write test script for Silverlight test automation in C#

    Also I am using WebUI Test Studio QA to record n play test scenario steps. Using one step, Test Studio found Silverlight control and when I checked FindLogic in the property window for the element found I see following expression

    [name 'Exact' TabsContainer] AND [XamlTag 'Exact' grid][XamlPath 'Exact' /radtabcontrol[automationid=Tabs]/grid[0]/raddockpanel[0]/layouttransformcontrol[name=HeaderDockedElement]/grid[name=RootVisual]/contentpresenter[name=ContentPresenter]/grid[0]/raddockpanel[0]/scrollviewer[automationid=ScrollViewerElement]/border[0]/grid[0]/scrollcontentpresenter[name=ScrollContentPresenter]/itemspresenter[0]/tabwrappanel[0]/radtabitem[0]]

    Now my question is how to write C# statement to find the same element. I wrote C# statement as followed but element is not found. Where I am going wrong in writing following statment ?

    FrameworkElement myElement = app.Find.ByExpression(new XamlFindExpression("Name=TabsContainer", "|", "XamlTag=ScrollViewer", "|", "XamlPath=/radtabcontrol[automationid=Tabs]/grid[0]/raddockpanel[0]/layouttransformcontrol[name=HeaderDockedElement]/grid[name=RootVisual]/contentpresenter[name=ContentPresenter]/grid[0]/raddockpanel[0]/scrollviewer[automationid=ScrollViewerElement]/border[0]/grid[0]/scrollcontentpresenter[name=ScrollContentPresenter]/itemspresenter[0]/tabwrappanel[0]/radtabitem[0]"));

    Thank You and Best Regards !

    / Yogesh
  2. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 11 Jan 2011 Link to this post

    Hi Yogesh,

    I am sorry you are running into this problem, but I think I see what the problem is. You don't need the "|" part. This special symbol means "then underneath the element you just found by the previous clauses find the following clauses".

    Try this instead:

    FrameworkElement myElement = app.Find.ByExpression(new XamlFindExpression("Name=TabsContainer", "XamlTag=ScrollViewer", "XamlPath=/radtabcontrol[automationid=Tabs]/grid[0]/raddockpanel[0]/layouttransformcontrol[name=HeaderDockedElement]/grid[name=RootVisual]/contentpresenter[name=ContentPresenter]/grid[0]/raddockpanel[0]/scrollviewer[automationid=ScrollViewerElement]/border[0]/grid[0]/scrollcontentpresenter[name=ScrollContentPresenter]/itemspresenter[0]/tabwrappanel[0]/radtabitem[0]"));

    The default is a logical AND condition i.e. find an element that has all of these properties.

    Kind regards,
    Cody
    the Telerik team
    Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
  3. Yogesh
    Yogesh avatar
    11 posts
    Member since:
    Jan 2011

    Posted 13 Jan 2011 Link to this post

    Hello Telerik,

    Well, unfortunately the solution you recommended did not work. I guess one can not locate element using XamlPATH. Is that right? Because when I look at end of the page at http://www.artoftest.com/support/webaii/topicsindex.aspx?topic=byexpression I don't see XamlPATH for building expression.

    Any idea how I can use XamlPath to locate elements using WebAii test framework where script is written in C# language.

    Best Regards !

    / Yogesh
  4. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 13 Jan 2011 Link to this post

    Hi Yogesh,

    Actually XamlPath should work. I just finished testing this code sample and got the expected results:

    FrameworkElement elem = ActiveBrowser.SilverlightApps()[0].Find.ByExpression(new XamlFindExpression("XamlTag=treelistviewvirtualizingpanel", "automationid=PART_GridViewVirtualizingPanel", "|", "XamlPath=/treelistviewrow[1]/border[0]/selectivescrollinggrid[name=grid]/gridviewtogglebutton[automationid=PART_ExpandButton]"));

    Which version of the framework are you using? Is your website publicly accessible? Can you send me a code sample I can run against your website to see what the problem might be?

    Best wishes,
    Cody
    the Telerik team
    Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
  5. Yogesh
    Yogesh avatar
    11 posts
    Member since:
    Jan 2011

    Posted 14 Jan 2011 Link to this post

    Hi,

    Thank you very much for all your help. My problem is solved. I can now find the element. I was making mistake in putting "|" symbol at wrong location.

    I used the following syntax and it worked

    FrameworkElement myElement = app.Find.ByExpression(new XamlFindExpression("Name=TabsContainer", "XamlTag=grid", "|", "XamlPath=/radtabcontrol[automationid=Tabs]/grid[0]/raddockpanel[0]/layouttransformcontrol[name=HeaderDockedElement]/grid[name=RootVisual]/contentpresenter[name=ContentPresenter]/grid[0]/raddockpanel[0]/scrollviewer[automationid=ScrollViewerElement]/border[0]/grid[0]/scrollcontentpresenter[name=ScrollContentPresenter]/itemspresenter[0]/tabwrappanel[0]/radtabitem[0]"));

    Best Regards !

    / Yogesh
  6. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 14 Jan 2011 Link to this post

    Hi Yogesh,

    Thank you very much for the update! I am both glad and relieved to hear you finally got it working the way you wanted. I will update our documentation to include XamPath in the list. Thanks for pointing out that it was missing. I have granted you 500 Telerik Points for pointing out this omission.

    Kind regards,
    Cody
    the Telerik team
    Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
Back to Top