Hi,
We are using Infragistics Test Advantage addon for WPF - version 2013.2 with UFT 12.02(patch2). I have .NET add in installed.
AUT is developed using: Infragistics Net advantage:2013 version 2
We have an XAM Data Grid where in one column, 3 WPF buttons are embeded in CellValue presenter (Infragistics.Windows.DataPresenter.CellValuePresenter)
From snoop, i am able to identify a stack panel, where it shows the children count as 7 out of which only 3 are currently visible.
StackPanel.Children (System.Windows.Controls.UIElementCollection)
How to access the properties of this stack panel.
StackPanel.Children[1].isVisible - shows true/false depending upon the visibility of buttons
Am able to access the CellValuepresenter using GetSubitemproperty method. but unable to find a way to access this children stack panel. Please guide
Attached the screenshot for reference.
Thanks,
Dhivya.D
Hi Dhivya,
I would use snoop to verify the exact position in the child elements under the control. But you should be able to use the TA CustomProperties FWElement, ContentElement, Children to dig through to the StackPanel and get access to the properties that you are looking for. The installed help gives an example of it at Working with WPF TestAutomation for HP > Accessing Controls' Properties > GetSubItemProperty. I also go into detail about this further in a Webinar located on youtube here: https://www.youtube.com/watch?v=j-_dQHVSt2U. In general you might want to watch from 18:07, but more specifically going into how to use snoop to in conjunction with testing at what you are looking for at 44:20.
Let me know if that helps,
Thanks for the suggestion. The video was very helpful.
I am able to dig through the child elements and identify the buttons and their properties.
set grid=WpfWindow("Home").XamDataGrid("Grid")intButCount=grid.GetSubItemProperty(gridCell,"{0}[0]","FWElement.Children[0].Children[3].Children[0].Children[0].ChildCount)
for j=0 to intButCount-1strActualButtonName=grid.GetSubItemProperty(gridCell,"{0}[0]","FWElement.Children[0].Children[3].Children[0].Children[0].Children["&j&"].Name") blnEnable=grid.GetSubItemProperty(gridCell,"{0}[0]","FWElement.Children[0].Children[3].Children[0].Children[0].Children["&j&"].IsEnabled") msgbox strActualButtonName & "--" & blnEnablenext
I have taken the child elements of the parent node (Contentvalue presenter) and its children (and inturn its children) to identify the stack panel.
From the snoop, object hierachy of the object is identified as:
<<Cellvaluepresenter>>.<<DockPanel>.<<Content Control -3rd child>>.<<ContentPresenter>>.<<Stack Panel>>ie: FWElement.Children[0].Children[3].Children[0].Children[0]
If there is a change in this object hierarchy then the above object identification will fail.
Instead, do we have any option to identify the child elements with some unique identification properties, for ex:I have to identify the content presenter inside FWElement??
Is there any other way to over come this issue??
Please suggest.
Thanks,Dhivya.D
Hi Dhivya, There is something to be said that if the object hierarchy changes significantly the test should fail. But there are ways around it. You can build a loop that finds a child element by any property or type you want as you have access to all the properties, and the Type names via Type.FullName or Type.Name. So you can do something like the following, this assumes that I am searching a Cell of XamDataGrid for a child element of Type Button with a Background color of red. You can of course modify it as you need. This may take a bit to run, you can speed it up by passing in a longer rootPath then just FWElement. Of course as long as you know your CellTemplate isn't going to change or if it does, that is a bug in the test that you know you will need to correct you can just hard code the path.
Set oGrid = WpfWindow("MainWindow").XamDataGrid("xdg") msgbox FindChildByTypeAndColor(oGrid, "{0}[Label]", "FWElement", "Button", "#FFFF0000") Function FindChildByTypeAndColor(grid, cellID, rootPath, typeCheck, colorCheck) NOTFound = "" ' Get the current FrameworkElement Type typeCrnt = grid.GetSubItemProperty(gridCell, cellID, rootPath & ".Type.Name") If typeCrnt = typeCheck Then ' If the type is what we were looking for lets check the other propert(y/ies) colorCrnt = grid.GetSubItemProperty(gridCell, cellID, rootPath & ".Background.ToString") If colorCrnt = colorCheck Then ' If we matched all the properties we were looking for then return the rootPath FindChildByTypeAndColor = rootPath Exit Function ' End If End If ' If we didn't find it, lets see how many children this has childCount = grid.GetSubItemProperty(gridCell, cellID, rootPath & ".ChildCount") If childCount = 0 Then ' No children, then we are on the wrong visual tree node, return back up FindChildByTypeAndColor = NOTFound Exit Function End If For i = 0 To childCount - 1 FindChildByTypeAndColor = FindChildByTypeAndColor(grid, cellID, rootPath & ".Children[" & CSTR(i) & "]", typeCheck, colorCheck) If FindChildByTypeAndColor <> NOTFound Then ' If the value was found in this call pass it back up to the previous call Exit Function End If Next 'If it hits here, it means it looped through all its children and didn't find it, set it to empty and pass it to the previous call FindChildByTypeAndColor = NOTFound Exit Function End Function
Hope this helps,
I'm trying to do something similar to what is being done in this post, but infragistics is throwing an error telling me that "[Children] is not an indexed property"Could someone tell me why that is?...
I need to get the text embedded in button that is embedded in the xamdatagrid cell so that I know what cell/button to click.
I tried the exact code given and it popped the same error
Hi Joseph,
I have arrived at the above mentioned code by identifying the exact object hierarchy using Snoop tool. So try to spy your AUT objects using Snoop and come up with FWelement code according your object hierarchy.