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

Help about XamlFindExpression

5 Answers 193 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Yogesh
Top achievements
Rank 1
Yogesh asked on 11 Jan 2011, 04:43 PM
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

5 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 11 Jan 2011, 07:32 PM
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
0
Yogesh
Top achievements
Rank 1
answered on 13 Jan 2011, 03:48 PM
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
0
Cody
Telerik team
answered on 14 Jan 2011, 03:43 AM
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
0
Yogesh
Top achievements
Rank 1
answered on 14 Jan 2011, 10:40 AM
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
0
Cody
Telerik team
answered on 14 Jan 2011, 02:42 PM
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
Tags
General Discussions
Asked by
Yogesh
Top achievements
Rank 1
Answers by
Cody
Telerik team
Yogesh
Top achievements
Rank 1
Share this question
or