Testing custom Silverlight controls without using AutomationPeer
My manager asked me to do some automated UI tests for our Silverlight application. The problem is that this application uses some custom controls, therefore I cannot programmatically access them right away.
The only way to access them is to use AutomationPeer, but my manager doesn't like th开发者_运维百科is idea, because it goes against testing principle to change the code in order to support UI automation; the code should be tested as-is.
Is there a method or a tool that will enable me to create automated Silverlight UI tests, without the use of AutomationPeer?
Your custom controls should support automated testing, but that same mechanism is how accessibility tools interact with them.
Tell your manager, 'I need to add accessibility support, and automation comes free'.
In short, if you can't automate your control, a blind, deaf, and/or limited mobility person can't use it anyway.
There are several solutions. One is you can write full support via a UITestExtionsPackage Take a look at these
http://blogs.msdn.com/b/gautamg/archive/2010/03/23/writing-extension-for-wpf-custom-control.aspx
http://blogs.msdn.com/b/mathew_aniyan/archive/2011/05/17/custom-wpf-control-s-custom-properties.aspx
However this solution might be a simpler one
http://blog.benday.com/archive/2011/07/18/Silverlight-Coded-UI-Tests-with-UserControls-amp-AutomationProperties.aspx
精彩评论