I have to build the UI testing framework for our Silverlight front-end using NUnit as the "driver". In SL2BETA2 I looked at UI Automation, but there were too many bugs (Name property returned as blank, etc). I turned to WebAii Silverlight Testing Framework
which shows a lot of promise, but there are also a quite a few bugs (which they promise to sort out in next release at the end of this month). One problem was a complete roadblock for me: The framework could not "see" any instance of the Popup class, which
we use to display dialogs... including our Logon form.
I decided to wait for SL2RC0 to see if problems in UI Automation had been solved. They were, but as it turns out the same Popup class problem exists. The most usefull information I could find was on
http://sivaprasaddotnet.blogspot.com/:
"If the custom control contains a Popup control, do not rely on walking the visual tree, because Popup content is in a separate visual tree. For example, ComboBoxAutomationPeer.GetChildrenCore should return a list of Automation peers that correspond to the
elements under the Popup control's visual tree."
Our front-end devlopers are not at all keen on getting rid of the Popup, as this seems to be a very usefull tool, but I can't get my tests to find the Popup, let alone click the Logon button contained in it.
Any help/advice/comments would be greatly appreciated! Do we need to derive from Popup and implement GetChildCore, and then use the custom class instead? Or what? I've been at this for a month and a half and have nothing to show for my effort except NUnit
tests that just opens a browser and navigates to our application url... not very impressive! This is critically urgent. Please help.
Johannes,
Although I haven't tried doing much UI auto of Popup yet, I have seen a few of the situations you talk about.
When dealing with popups, if the popup is a part of your control template, you should be able to get it by casting to a FrameworkElement (maybe), almost like the WPF logical tree helper.
If you have some leeway, you may be able to add some helper code to the control to get in there... here's an example going the other direction, from the popup child to the logical parent, the reverse.
DependencyObject parent = VisualTreeHelper.GetParent(myDepObj);
if (parent == null)
{
FrameworkElement element = myDepObj as FrameworkElement;
if (element != null)
{
parent = element.Parent;
}
}
myDepObj = parent;
Let me know if this might get you anywhere... sorry I don't have a complete answer for you right now.
Senior Software Development Engineer ~ Silverlight for Windows Phone
This posting is provided "AS IS" with no warranties, and confers no rights.
The answer turned out to be quite involved. First we had to implement a "stack" in our manager class to keep track of the open Popups... which represent modal dialogs. Then we added a method to get the top most popup from this stack... if the stack is not
empty.
Next I added an AutomationPeer for the application Page class. In the AutomationPeer I overrode the GetChildrenCore, where would check if there were open Popups. If there ween't, I would simply call base.GetChildrenCore. If there IS a Popup open, the logic
is that UI Automation only needs to know about that Popup and nothing elese, as the Popup is modal and block everyting else. I basically then just manuallyadded the Popup.Child (whicj is a canvas in our case) the the result of GetChildrenCore. Voila.
A bit more work than I had hoped for, but a clean enough solution to convince the front-end guys it was worth it.
Hi, actually I did the same some weeks ago. But now I'm struggling with the fact that the GetParent-Call on the AutomationPeers of the Dialog instances return null. This leads to an inconsistency of the Peer tree because the parent window lists the Dialog AutomationPeer
but this Peer returns no parent. Any hints? Regards Martin
johannes.ack...
0 Points
2 Posts
Popup class and UI Automation
Oct 14, 2008 07:57 AM | LINK
Hi all,
I have to build the UI testing framework for our Silverlight front-end using NUnit as the "driver". In SL2BETA2 I looked at UI Automation, but there were too many bugs (Name property returned as blank, etc). I turned to WebAii Silverlight Testing Framework which shows a lot of promise, but there are also a quite a few bugs (which they promise to sort out in next release at the end of this month). One problem was a complete roadblock for me: The framework could not "see" any instance of the Popup class, which we use to display dialogs... including our Logon form.
I decided to wait for SL2RC0 to see if problems in UI Automation had been solved. They were, but as it turns out the same Popup class problem exists. The most usefull information I could find was on http://sivaprasaddotnet.blogspot.com/:
"If the custom control contains a Popup control, do not rely on walking the visual tree, because Popup content is in a separate visual tree. For example, ComboBoxAutomationPeer.GetChildrenCore should return a list of Automation peers that correspond to the elements under the Popup control's visual tree."
Our front-end devlopers are not at all keen on getting rid of the Popup, as this seems to be a very usefull tool, but I can't get my tests to find the Popup, let alone click the Logon button contained in it.
Any help/advice/comments would be greatly appreciated! Do we need to derive from Popup and implement GetChildCore, and then use the custom class instead? Or what? I've been at this for a month and a half and have nothing to show for my effort except NUnit tests that just opens a browser and navigates to our application url... not very impressive! This is critically urgent. Please help.
Cheers,
Johannes Ackermann
JWilcox
Participant
1106 Points
195 Posts
Microsoft
Re: Popup class and UI Automation
Oct 14, 2008 09:06 AM | LINK
Johannes,
Although I haven't tried doing much UI auto of Popup yet, I have seen a few of the situations you talk about.
When dealing with popups, if the popup is a part of your control template, you should be able to get it by casting to a FrameworkElement (maybe), almost like the WPF logical tree helper.
If you have some leeway, you may be able to add some helper code to the control to get in there... here's an example going the other direction, from the popup child to the logical parent, the reverse.
DependencyObject parent = VisualTreeHelper.GetParent(myDepObj); if (parent == null) { FrameworkElement element = myDepObj as FrameworkElement; if (element != null) { parent = element.Parent; } } myDepObj = parent;Let me know if this might get you anywhere... sorry I don't have a complete answer for you right now.
This posting is provided "AS IS" with no warranties, and confers no rights.
johannes.ack...
0 Points
2 Posts
Re: Re: Popup class and UI Automation
Oct 23, 2008 06:05 AM | LINK
The answer turned out to be quite involved. First we had to implement a "stack" in our manager class to keep track of the open Popups... which represent modal dialogs. Then we added a method to get the top most popup from this stack... if the stack is not empty.
Next I added an AutomationPeer for the application Page class. In the AutomationPeer I overrode the GetChildrenCore, where would check if there were open Popups. If there ween't, I would simply call base.GetChildrenCore. If there IS a Popup open, the logic is that UI Automation only needs to know about that Popup and nothing elese, as the Popup is modal and block everyting else. I basically then just manuallyadded the Popup.Child (whicj is a canvas in our case) the the result of GetChildrenCore. Voila.
A bit more work than I had hoped for, but a clean enough solution to convince the front-end guys it was worth it.
Cheers.
mboe
Member
2 Points
1 Post
Re: Re: Re: Popup class and UI Automation
Feb 08, 2010 11:38 AM | LINK
KiranChandran
Member
2 Points
1 Post
Re: Popup class and UI Automation
Jun 24, 2010 08:49 PM | LINK
Check the below link
http://www.artoftest.com/community/forums/webaii-automation-framework/forum-silverlight-automation/finding-modal-popups.aspx
and
http://blogs.telerik.com/testing/posts/10-05-19/silverlight_childwindow_and_popup_support_in_webui_test_studio_and_webaii_testing_framework.aspx