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 this 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
Related
I am using UI Automation library - TestStack.White to automate a Windows Application, where I utilize Inspect.exe to get the UI Elements from the WinForms. I have had no issues with the Inspect.exe so far except currently I am stuck with an issue in my development machine where the tool started recognizing the "Buttons" as "Pane" and the behavior is same across Visual UIA Verify, TestStack(White). Eventually all the tests are getting failed since it couldn't identify the Buttons (returns Null).
Here's what it looks like now,
[]
Here's what it used to look and it looks in a Fresh VM,
Expected,
[]
Can someone please through some light regarding this behavior or point out what would have gone wrong here ?
Thanks in Advance !
Hmm... It looks like a bug in UIAutomationCore.dll or a target application issue. I think you can't do something with that on client side. But some workarounds are possible. It's still recognized as a class name with BUTTON inside. So it's possible to do some part of your automation with a tool that can support both UI Automation (for complicated controls like WinForms list views etc) and Win32 API (like here, when it has NativeWindowHandle and adequate ClassName).
If you can consider changing the automation tool, one of the options is pywinauto. It can use Win32 API or UI Automation under the hood by your choice. The high level API is almost the same. So you can easily switch between 2 backends for different actions (having 2 different Application objects connected to one target app instance). Getting Started Guide will bring you initial guidance for the core concept.
I was a .net based windows application developer and being a web developer now.
For the last couple of years, I tried to follow principles of Specification by example in a project.
On the last project I was involved, our team used WPF with MVVM(Model-View-ViewModel) pattern and I tried SpecFlow for testing. (Well.. the coverage by SpecFlow was very low though cause it was not officially adopted from our team and I couldn't spend enough time on it.)
Now our team started to migrate the existing windows application to a web based application and decided to use cucumber.js as a tool for implementing 'Specification by example'.
When I was trying SpecFlow before, I made all the step definitions to test ViewModel layer instead of View and it was the only way actually. What I'm confused with cucumber.js is that most of examples demonstrate how to test features via web browsers(headless or real ones).
If the features are specifying specific ui behaviors then accessing a DOM element and evaluating its value make sense. However, as far as I learned about Specification by examples, testing under the UI layer is recommended instead of UI elements directly.
It seems like most of modern web applications have layers such as MVC, MVVM(knouckout.js) nowadays. Our web application will use Angularjs and this is my theory.
I guess it is possible to use feature files - which do not state any specific UI controls and behaviors - to test under the skin of UI layer, without relying browser support. That layer would be Model of angularjs, not ui elements.
Is this approach missing something or wrong with cucumber.js?
Please give me some insights and correct me if I'm wrong.
Thanks in advance!
Specification by example specifies requirements by giving examples from the point of view of the user. What's more representative of the user: clicking items on a web page, or directly calling code? A user won't be calling methods on your view model, so in my opinion a feature test is a much better way to test expected behaviour.
I need a test automation tool for Silverlight. Basically, I need a tool that would simulate users accessing, clicking buttons etc. on a Silverlight UI.
A google search has turned up several promising leads:
WebAii
White
Selenium-Silverlight
NeoLoad
I need to know what the pros and cons of each of them are, and of any other suitable tools for this purpose.
I would prefer a open source tool but am not averse to a proprietary one if necessary.
There's one available in SL4 for unit testing
It's quite handy if you do MVVM to write unit tests against your models
I know virtually nothing about Silverlight. I'm considering creating a browser based app and really don't know if it should be built using Silverlight or ASP.NET (which I am familiar with). I'm curious as to the reasons why a developer chooses to use Silverlight.
Thanks very much.
ASP.NET and Silverlight aren't comparable.
Silverlight is a client-side framework, comparable (perhaps) only to Adobe's Flash while ASP.NET is a server-side framework.
You use those in conjuction, not one instead of the other and they're not connected in any way.
There are a few reasons you may want to consider using Silverlight:
You have a need for great looking and
interactive web applications (that
are not Ajax, jQuery, etc.).
You want to utilize your current
programming language (VB.NET, C#,
etc) skills.
You want your "web app" to be
available out-of-the browser.
There are other reasons - have a read: Top 10 Reasons to Use Silverlight. There can be a signifcant ramp you would need to make, but once made, you may prefer SL for certain things over ASP.NET and even in some cases, not really have option available to you in ASP.NET, like, for example, perspective transforms of images that can be animated from user interactively.
If you are building something that requires lots of UI interaction, and is reasonably non-static with its presentation then i would suggest Silverlight.
If you are doing (relatively) simple UI (i.e. tabular based presentation of data like clients and orders) with not too much UI trickery then i would suggest that you stick with ASP.NET.
Having done both, i find that Silverlight kicks butt when it comes to doing complex UI stuff, or you need to eliminate callbacks and postbacks to the server.
Reuse .NET code and skill on the client browser.
Achieve high performance.
Use Silverlight if you want a flash type site without using Flash. If you want to use the .NET stack Silverlight is the way to go to do what flash can do.
Silverlight was originally known as WPF/E. It is a light version of Windows Presentation Foundation, designed for the web and embedded devices.
But yes, you can think of it as Microsoft Flash.
You could also try using web standards also, sprinkled with some Jquery and Ajax, with maybe Modernizr to use html5. What do you need to do with this exactly?
Because it's the only option for third party software development on the upcoming Windows Phone 7 platform. (OK, also XNA, but that's for games)
Oh, and they also use it on the Web for some reason.
I want to automate the application develoepd in silverlight. Can you let me know whether there are any open source tools are available which can be used for automating SilverLight app. Thanks.
We are doing UI testing on a Silverlight application using the UIAutomation API, and it works very nicely.
Project White is a library that sits on top of UIAutomation, and many people find it helpful. I prefer to use the UIAutomation APIs directly - it's really not as hard as you might think, as my tutorial shows.
If you're looking to perform User Interface Automation (UIA) to simulate mouse clicks, keyboard presses, etc. there is no "easy" way to get this today.
I've seen some third party tools that may work, such as Telerik's. Note that I have not used and do not endorse this, just know it is out there!
I am currently trying out Project White and finding it quite easy to use.
Before using Project White I tried out WiPFlash which was also rather easy to use. It just lacked a few features that I was after (Right Click and Drag options).